babylon.d.txt 2.9 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114
  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. let Epsilon: number;
  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 current color in rgb space to HSV values
  464. * @returns a new color3 representing the HSV values
  465. */
  466. toHSV(): Color3;
  467. /**
  468. * Converts current color in rgb space to HSV values
  469. * @param result defines the Color3 where to store the HSV values
  470. */
  471. toHSVToRef(result: Color3): void;
  472. /**
  473. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  474. * @param convertedColor defines the Color3 object where to store the linear space version
  475. * @returns the unmodified Color3
  476. */
  477. toLinearSpaceToRef(convertedColor: Color3): Color3;
  478. /**
  479. * Computes a new Color3 converted from the current one to gamma space
  480. * @returns a new Color3 object
  481. */
  482. toGammaSpace(): Color3;
  483. /**
  484. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  485. * @param convertedColor defines the Color3 object where to store the gamma space version
  486. * @returns the unmodified Color3
  487. */
  488. toGammaSpaceToRef(convertedColor: Color3): Color3;
  489. private static _BlackReadOnly;
  490. /**
  491. * Convert Hue, saturation and value to a Color3 (RGB)
  492. * @param hue defines the hue
  493. * @param saturation defines the saturation
  494. * @param value defines the value
  495. * @param result defines the Color3 where to store the RGB values
  496. */
  497. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  498. /**
  499. * Creates a new Color3 from the string containing valid hexadecimal values
  500. * @param hex defines a string containing valid hexadecimal values
  501. * @returns a new Color3 object
  502. */
  503. static FromHexString(hex: string): Color3;
  504. /**
  505. * Creates a new Color3 from the starting index of the given array
  506. * @param array defines the source array
  507. * @param offset defines an offset in the source array
  508. * @returns a new Color3 object
  509. */
  510. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  511. /**
  512. * Creates a new Color3 from integer values (< 256)
  513. * @param r defines the red component to read from (value between 0 and 255)
  514. * @param g defines the green component to read from (value between 0 and 255)
  515. * @param b defines the blue component to read from (value between 0 and 255)
  516. * @returns a new Color3 object
  517. */
  518. static FromInts(r: number, g: number, b: number): Color3;
  519. /**
  520. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  521. * @param start defines the start Color3 value
  522. * @param end defines the end Color3 value
  523. * @param amount defines the gradient value between start and end
  524. * @returns a new Color3 object
  525. */
  526. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  527. /**
  528. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  529. * @param left defines the start value
  530. * @param right defines the end value
  531. * @param amount defines the gradient factor
  532. * @param result defines the Color3 object where to store the result
  533. */
  534. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  535. /**
  536. * Returns a Color3 value containing a red color
  537. * @returns a new Color3 object
  538. */
  539. static Red(): Color3;
  540. /**
  541. * Returns a Color3 value containing a green color
  542. * @returns a new Color3 object
  543. */
  544. static Green(): Color3;
  545. /**
  546. * Returns a Color3 value containing a blue color
  547. * @returns a new Color3 object
  548. */
  549. static Blue(): Color3;
  550. /**
  551. * Returns a Color3 value containing a black color
  552. * @returns a new Color3 object
  553. */
  554. static Black(): Color3;
  555. /**
  556. * Gets a Color3 value containing a black color that must not be updated
  557. */
  558. static readonly BlackReadOnly: DeepImmutable<Color3>;
  559. /**
  560. * Returns a Color3 value containing a white color
  561. * @returns a new Color3 object
  562. */
  563. static White(): Color3;
  564. /**
  565. * Returns a Color3 value containing a purple color
  566. * @returns a new Color3 object
  567. */
  568. static Purple(): Color3;
  569. /**
  570. * Returns a Color3 value containing a magenta color
  571. * @returns a new Color3 object
  572. */
  573. static Magenta(): Color3;
  574. /**
  575. * Returns a Color3 value containing a yellow color
  576. * @returns a new Color3 object
  577. */
  578. static Yellow(): Color3;
  579. /**
  580. * Returns a Color3 value containing a gray color
  581. * @returns a new Color3 object
  582. */
  583. static Gray(): Color3;
  584. /**
  585. * Returns a Color3 value containing a teal color
  586. * @returns a new Color3 object
  587. */
  588. static Teal(): Color3;
  589. /**
  590. * Returns a Color3 value containing a random color
  591. * @returns a new Color3 object
  592. */
  593. static Random(): Color3;
  594. }
  595. /**
  596. * Class used to hold a RBGA color
  597. */
  598. export class Color4 {
  599. /**
  600. * Defines the red component (between 0 and 1, default is 0)
  601. */
  602. r: number;
  603. /**
  604. * Defines the green component (between 0 and 1, default is 0)
  605. */
  606. g: number;
  607. /**
  608. * Defines the blue component (between 0 and 1, default is 0)
  609. */
  610. b: number;
  611. /**
  612. * Defines the alpha component (between 0 and 1, default is 1)
  613. */
  614. a: number;
  615. /**
  616. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  617. * @param r defines the red component (between 0 and 1, default is 0)
  618. * @param g defines the green component (between 0 and 1, default is 0)
  619. * @param b defines the blue component (between 0 and 1, default is 0)
  620. * @param a defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. constructor(
  623. /**
  624. * Defines the red component (between 0 and 1, default is 0)
  625. */
  626. r?: number,
  627. /**
  628. * Defines the green component (between 0 and 1, default is 0)
  629. */
  630. g?: number,
  631. /**
  632. * Defines the blue component (between 0 and 1, default is 0)
  633. */
  634. b?: number,
  635. /**
  636. * Defines the alpha component (between 0 and 1, default is 1)
  637. */
  638. a?: number);
  639. /**
  640. * Adds in place the given Color4 values to the current Color4 object
  641. * @param right defines the second operand
  642. * @returns the current updated Color4 object
  643. */
  644. addInPlace(right: DeepImmutable<Color4>): Color4;
  645. /**
  646. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  647. * @returns the new array
  648. */
  649. asArray(): number[];
  650. /**
  651. * Stores from the starting index in the given array the Color4 successive values
  652. * @param array defines the array where to store the r,g,b components
  653. * @param index defines an optional index in the target array to define where to start storing values
  654. * @returns the current Color4 object
  655. */
  656. toArray(array: number[], index?: number): Color4;
  657. /**
  658. * Determines equality between Color4 objects
  659. * @param otherColor defines the second operand
  660. * @returns true if the rgba values are equal to the given ones
  661. */
  662. equals(otherColor: DeepImmutable<Color4>): boolean;
  663. /**
  664. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  665. * @param right defines the second operand
  666. * @returns a new Color4 object
  667. */
  668. add(right: DeepImmutable<Color4>): Color4;
  669. /**
  670. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  671. * @param right defines the second operand
  672. * @returns a new Color4 object
  673. */
  674. subtract(right: DeepImmutable<Color4>): Color4;
  675. /**
  676. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  677. * @param right defines the second operand
  678. * @param result defines the Color4 object where to store the result
  679. * @returns the current Color4 object
  680. */
  681. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  682. /**
  683. * Creates a new Color4 with the current Color4 values multiplied by scale
  684. * @param scale defines the scaling factor to apply
  685. * @returns a new Color4 object
  686. */
  687. scale(scale: number): Color4;
  688. /**
  689. * Multiplies the current Color4 values by scale and stores the result in "result"
  690. * @param scale defines the scaling factor to apply
  691. * @param result defines the Color4 object where to store the result
  692. * @returns the current unmodified Color4
  693. */
  694. scaleToRef(scale: number, result: Color4): Color4;
  695. /**
  696. * Scale the current Color4 values by a factor and add the result to a given Color4
  697. * @param scale defines the scale factor
  698. * @param result defines the Color4 object where to store the result
  699. * @returns the unmodified current Color4
  700. */
  701. scaleAndAddToRef(scale: number, result: Color4): Color4;
  702. /**
  703. * Clamps the rgb values by the min and max values and stores the result into "result"
  704. * @param min defines minimum clamping value (default is 0)
  705. * @param max defines maximum clamping value (default is 1)
  706. * @param result defines color to store the result into.
  707. * @returns the cuurent Color4
  708. */
  709. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  710. /**
  711. * Multipy an Color4 value by another and return a new Color4 object
  712. * @param color defines the Color4 value to multiply by
  713. * @returns a new Color4 object
  714. */
  715. multiply(color: Color4): Color4;
  716. /**
  717. * Multipy a Color4 value by another and push the result in a reference value
  718. * @param color defines the Color4 value to multiply by
  719. * @param result defines the Color4 to fill the result in
  720. * @returns the result Color4
  721. */
  722. multiplyToRef(color: Color4, result: Color4): Color4;
  723. /**
  724. * Creates a string with the Color4 current values
  725. * @returns the string representation of the Color4 object
  726. */
  727. toString(): string;
  728. /**
  729. * Returns the string "Color4"
  730. * @returns "Color4"
  731. */
  732. getClassName(): string;
  733. /**
  734. * Compute the Color4 hash code
  735. * @returns an unique number that can be used to hash Color4 objects
  736. */
  737. getHashCode(): number;
  738. /**
  739. * Creates a new Color4 copied from the current one
  740. * @returns a new Color4 object
  741. */
  742. clone(): Color4;
  743. /**
  744. * Copies the given Color4 values into the current one
  745. * @param source defines the source Color4 object
  746. * @returns the current updated Color4 object
  747. */
  748. copyFrom(source: Color4): Color4;
  749. /**
  750. * Copies the given float values into the current one
  751. * @param r defines the red component to read from
  752. * @param g defines the green component to read from
  753. * @param b defines the blue component to read from
  754. * @param a defines the alpha component to read from
  755. * @returns the current updated Color4 object
  756. */
  757. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  758. /**
  759. * Copies the given float values into the current one
  760. * @param r defines the red component to read from
  761. * @param g defines the green component to read from
  762. * @param b defines the blue component to read from
  763. * @param a defines the alpha component to read from
  764. * @returns the current updated Color4 object
  765. */
  766. set(r: number, g: number, b: number, a: number): Color4;
  767. /**
  768. * Compute the Color4 hexadecimal code as a string
  769. * @returns a string containing the hexadecimal representation of the Color4 object
  770. */
  771. toHexString(): string;
  772. /**
  773. * Computes a new Color4 converted from the current one to linear space
  774. * @returns a new Color4 object
  775. */
  776. toLinearSpace(): Color4;
  777. /**
  778. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  779. * @param convertedColor defines the Color4 object where to store the linear space version
  780. * @returns the unmodified Color4
  781. */
  782. toLinearSpaceToRef(convertedColor: Color4): Color4;
  783. /**
  784. * Computes a new Color4 converted from the current one to gamma space
  785. * @returns a new Color4 object
  786. */
  787. toGammaSpace(): Color4;
  788. /**
  789. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  790. * @param convertedColor defines the Color4 object where to store the gamma space version
  791. * @returns the unmodified Color4
  792. */
  793. toGammaSpaceToRef(convertedColor: Color4): Color4;
  794. /**
  795. * Creates a new Color4 from the string containing valid hexadecimal values
  796. * @param hex defines a string containing valid hexadecimal values
  797. * @returns a new Color4 object
  798. */
  799. static FromHexString(hex: string): Color4;
  800. /**
  801. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  802. * @param left defines the start value
  803. * @param right defines the end value
  804. * @param amount defines the gradient factor
  805. * @returns a new Color4 object
  806. */
  807. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  808. /**
  809. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  810. * @param left defines the start value
  811. * @param right defines the end value
  812. * @param amount defines the gradient factor
  813. * @param result defines the Color4 object where to store data
  814. */
  815. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  816. /**
  817. * Creates a new Color4 from a Color3 and an alpha value
  818. * @param color3 defines the source Color3 to read from
  819. * @param alpha defines the alpha component (1.0 by default)
  820. * @returns a new Color4 object
  821. */
  822. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  823. /**
  824. * Creates a new Color4 from the starting index element of the given array
  825. * @param array defines the source array to read from
  826. * @param offset defines the offset in the source array
  827. * @returns a new Color4 object
  828. */
  829. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  830. /**
  831. * Creates a new Color3 from integer values (< 256)
  832. * @param r defines the red component to read from (value between 0 and 255)
  833. * @param g defines the green component to read from (value between 0 and 255)
  834. * @param b defines the blue component to read from (value between 0 and 255)
  835. * @param a defines the alpha component to read from (value between 0 and 255)
  836. * @returns a new Color3 object
  837. */
  838. static FromInts(r: number, g: number, b: number, a: number): Color4;
  839. /**
  840. * Check the content of a given array and convert it to an array containing RGBA data
  841. * If the original array was already containing count * 4 values then it is returned directly
  842. * @param colors defines the array to check
  843. * @param count defines the number of RGBA data to expect
  844. * @returns an array containing count * 4 values (RGBA)
  845. */
  846. static CheckColors4(colors: number[], count: number): number[];
  847. }
  848. /**
  849. * Class representing a vector containing 2 coordinates
  850. */
  851. export class Vector2 {
  852. /** defines the first coordinate */
  853. x: number;
  854. /** defines the second coordinate */
  855. y: number;
  856. /**
  857. * Creates a new Vector2 from the given x and y coordinates
  858. * @param x defines the first coordinate
  859. * @param y defines the second coordinate
  860. */
  861. constructor(
  862. /** defines the first coordinate */
  863. x?: number,
  864. /** defines the second coordinate */
  865. y?: number);
  866. /**
  867. * Gets a string with the Vector2 coordinates
  868. * @returns a string with the Vector2 coordinates
  869. */
  870. toString(): string;
  871. /**
  872. * Gets class name
  873. * @returns the string "Vector2"
  874. */
  875. getClassName(): string;
  876. /**
  877. * Gets current vector hash code
  878. * @returns the Vector2 hash code as a number
  879. */
  880. getHashCode(): number;
  881. /**
  882. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  883. * @param array defines the source array
  884. * @param index defines the offset in source array
  885. * @returns the current Vector2
  886. */
  887. toArray(array: FloatArray, index?: number): Vector2;
  888. /**
  889. * Copy the current vector to an array
  890. * @returns a new array with 2 elements: the Vector2 coordinates.
  891. */
  892. asArray(): number[];
  893. /**
  894. * Sets the Vector2 coordinates with the given Vector2 coordinates
  895. * @param source defines the source Vector2
  896. * @returns the current updated Vector2
  897. */
  898. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  899. /**
  900. * Sets the Vector2 coordinates with the given floats
  901. * @param x defines the first coordinate
  902. * @param y defines the second coordinate
  903. * @returns the current updated Vector2
  904. */
  905. copyFromFloats(x: number, y: number): Vector2;
  906. /**
  907. * Sets the Vector2 coordinates with the given floats
  908. * @param x defines the first coordinate
  909. * @param y defines the second coordinate
  910. * @returns the current updated Vector2
  911. */
  912. set(x: number, y: number): Vector2;
  913. /**
  914. * Add another vector with the current one
  915. * @param otherVector defines the other vector
  916. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  917. */
  918. add(otherVector: DeepImmutable<Vector2>): Vector2;
  919. /**
  920. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  921. * @param otherVector defines the other vector
  922. * @param result defines the target vector
  923. * @returns the unmodified current Vector2
  924. */
  925. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  926. /**
  927. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  928. * @param otherVector defines the other vector
  929. * @returns the current updated Vector2
  930. */
  931. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  932. /**
  933. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  934. * @param otherVector defines the other vector
  935. * @returns a new Vector2
  936. */
  937. addVector3(otherVector: Vector3): Vector2;
  938. /**
  939. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  940. * @param otherVector defines the other vector
  941. * @returns a new Vector2
  942. */
  943. subtract(otherVector: Vector2): Vector2;
  944. /**
  945. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  946. * @param otherVector defines the other vector
  947. * @param result defines the target vector
  948. * @returns the unmodified current Vector2
  949. */
  950. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  951. /**
  952. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  953. * @param otherVector defines the other vector
  954. * @returns the current updated Vector2
  955. */
  956. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  957. /**
  958. * Multiplies in place the current Vector2 coordinates by the given ones
  959. * @param otherVector defines the other vector
  960. * @returns the current updated Vector2
  961. */
  962. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  963. /**
  964. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  965. * @param otherVector defines the other vector
  966. * @returns a new Vector2
  967. */
  968. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  969. /**
  970. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  971. * @param otherVector defines the other vector
  972. * @param result defines the target vector
  973. * @returns the unmodified current Vector2
  974. */
  975. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  976. /**
  977. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  978. * @param x defines the first coordinate
  979. * @param y defines the second coordinate
  980. * @returns a new Vector2
  981. */
  982. multiplyByFloats(x: number, y: number): Vector2;
  983. /**
  984. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  985. * @param otherVector defines the other vector
  986. * @returns a new Vector2
  987. */
  988. divide(otherVector: Vector2): Vector2;
  989. /**
  990. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  991. * @param otherVector defines the other vector
  992. * @param result defines the target vector
  993. * @returns the unmodified current Vector2
  994. */
  995. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  996. /**
  997. * Divides the current Vector2 coordinates by the given ones
  998. * @param otherVector defines the other vector
  999. * @returns the current updated Vector2
  1000. */
  1001. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1002. /**
  1003. * Gets a new Vector2 with current Vector2 negated coordinates
  1004. * @returns a new Vector2
  1005. */
  1006. negate(): Vector2;
  1007. /**
  1008. * Multiply the Vector2 coordinates by scale
  1009. * @param scale defines the scaling factor
  1010. * @returns the current updated Vector2
  1011. */
  1012. scaleInPlace(scale: number): Vector2;
  1013. /**
  1014. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1015. * @param scale defines the scaling factor
  1016. * @returns a new Vector2
  1017. */
  1018. scale(scale: number): Vector2;
  1019. /**
  1020. * Scale the current Vector2 values by a factor to a given Vector2
  1021. * @param scale defines the scale factor
  1022. * @param result defines the Vector2 object where to store the result
  1023. * @returns the unmodified current Vector2
  1024. */
  1025. scaleToRef(scale: number, result: Vector2): Vector2;
  1026. /**
  1027. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1028. * @param scale defines the scale factor
  1029. * @param result defines the Vector2 object where to store the result
  1030. * @returns the unmodified current Vector2
  1031. */
  1032. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1033. /**
  1034. * Gets a boolean if two vectors are equals
  1035. * @param otherVector defines the other vector
  1036. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1037. */
  1038. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1039. /**
  1040. * Gets a boolean if two vectors are equals (using an epsilon value)
  1041. * @param otherVector defines the other vector
  1042. * @param epsilon defines the minimal distance to consider equality
  1043. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1044. */
  1045. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1046. /**
  1047. * Gets a new Vector2 from current Vector2 floored values
  1048. * @returns a new Vector2
  1049. */
  1050. floor(): Vector2;
  1051. /**
  1052. * Gets a new Vector2 from current Vector2 floored values
  1053. * @returns a new Vector2
  1054. */
  1055. fract(): Vector2;
  1056. /**
  1057. * Gets the length of the vector
  1058. * @returns the vector length (float)
  1059. */
  1060. length(): number;
  1061. /**
  1062. * Gets the vector squared length
  1063. * @returns the vector squared length (float)
  1064. */
  1065. lengthSquared(): number;
  1066. /**
  1067. * Normalize the vector
  1068. * @returns the current updated Vector2
  1069. */
  1070. normalize(): Vector2;
  1071. /**
  1072. * Gets a new Vector2 copied from the Vector2
  1073. * @returns a new Vector2
  1074. */
  1075. clone(): Vector2;
  1076. /**
  1077. * Gets a new Vector2(0, 0)
  1078. * @returns a new Vector2
  1079. */
  1080. static Zero(): Vector2;
  1081. /**
  1082. * Gets a new Vector2(1, 1)
  1083. * @returns a new Vector2
  1084. */
  1085. static One(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 set from the given index element of the given array
  1088. * @param array defines the data source
  1089. * @param offset defines the offset in the data source
  1090. * @returns a new Vector2
  1091. */
  1092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1093. /**
  1094. * Sets "result" from the given index element of the given array
  1095. * @param array defines the data source
  1096. * @param offset defines the offset in the data source
  1097. * @param result defines the target vector
  1098. */
  1099. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1100. /**
  1101. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1102. * @param value1 defines 1st point of control
  1103. * @param value2 defines 2nd point of control
  1104. * @param value3 defines 3rd point of control
  1105. * @param value4 defines 4th point of control
  1106. * @param amount defines the interpolation factor
  1107. * @returns a new Vector2
  1108. */
  1109. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1110. /**
  1111. * 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".
  1112. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1113. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1114. * @param value defines the value to clamp
  1115. * @param min defines the lower limit
  1116. * @param max defines the upper limit
  1117. * @returns a new Vector2
  1118. */
  1119. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1120. /**
  1121. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1122. * @param value1 defines the 1st control point
  1123. * @param tangent1 defines the outgoing tangent
  1124. * @param value2 defines the 2nd control point
  1125. * @param tangent2 defines the incoming tangent
  1126. * @param amount defines the interpolation factor
  1127. * @returns a new Vector2
  1128. */
  1129. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1130. /**
  1131. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1132. * @param start defines the start vector
  1133. * @param end defines the end vector
  1134. * @param amount defines the interpolation factor
  1135. * @returns a new Vector2
  1136. */
  1137. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1138. /**
  1139. * Gets the dot product of the vector "left" and the vector "right"
  1140. * @param left defines first vector
  1141. * @param right defines second vector
  1142. * @returns the dot product (float)
  1143. */
  1144. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1145. /**
  1146. * Returns a new Vector2 equal to the normalized given vector
  1147. * @param vector defines the vector to normalize
  1148. * @returns a new Vector2
  1149. */
  1150. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1151. /**
  1152. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1153. * @param left defines 1st vector
  1154. * @param right defines 2nd vector
  1155. * @returns a new Vector2
  1156. */
  1157. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1158. /**
  1159. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1160. * @param left defines 1st vector
  1161. * @param right defines 2nd vector
  1162. * @returns a new Vector2
  1163. */
  1164. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1165. /**
  1166. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1167. * @param vector defines the vector to transform
  1168. * @param transformation defines the matrix to apply
  1169. * @returns a new Vector2
  1170. */
  1171. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1172. /**
  1173. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1174. * @param vector defines the vector to transform
  1175. * @param transformation defines the matrix to apply
  1176. * @param result defines the target vector
  1177. */
  1178. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1179. /**
  1180. * Determines if a given vector is included in a triangle
  1181. * @param p defines the vector to test
  1182. * @param p0 defines 1st triangle point
  1183. * @param p1 defines 2nd triangle point
  1184. * @param p2 defines 3rd triangle point
  1185. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1186. */
  1187. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1188. /**
  1189. * Gets the distance between the vectors "value1" and "value2"
  1190. * @param value1 defines first vector
  1191. * @param value2 defines second vector
  1192. * @returns the distance between vectors
  1193. */
  1194. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1195. /**
  1196. * Returns the squared distance between the vectors "value1" and "value2"
  1197. * @param value1 defines first vector
  1198. * @param value2 defines second vector
  1199. * @returns the squared distance between vectors
  1200. */
  1201. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1202. /**
  1203. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1204. * @param value1 defines first vector
  1205. * @param value2 defines second vector
  1206. * @returns a new Vector2
  1207. */
  1208. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1209. /**
  1210. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1211. * @param p defines the middle point
  1212. * @param segA defines one point of the segment
  1213. * @param segB defines the other point of the segment
  1214. * @returns the shortest distance
  1215. */
  1216. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1217. }
  1218. /**
  1219. * Classed used to store (x,y,z) vector representation
  1220. * A Vector3 is the main object used in 3D geometry
  1221. * It can represent etiher the coordinates of a point the space, either a direction
  1222. * Reminder: js uses a left handed forward facing system
  1223. */
  1224. export class Vector3 {
  1225. /**
  1226. * Defines the first coordinates (on X axis)
  1227. */
  1228. x: number;
  1229. /**
  1230. * Defines the second coordinates (on Y axis)
  1231. */
  1232. y: number;
  1233. /**
  1234. * Defines the third coordinates (on Z axis)
  1235. */
  1236. z: number;
  1237. private static _UpReadOnly;
  1238. private static _ZeroReadOnly;
  1239. /**
  1240. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1241. * @param x defines the first coordinates (on X axis)
  1242. * @param y defines the second coordinates (on Y axis)
  1243. * @param z defines the third coordinates (on Z axis)
  1244. */
  1245. constructor(
  1246. /**
  1247. * Defines the first coordinates (on X axis)
  1248. */
  1249. x?: number,
  1250. /**
  1251. * Defines the second coordinates (on Y axis)
  1252. */
  1253. y?: number,
  1254. /**
  1255. * Defines the third coordinates (on Z axis)
  1256. */
  1257. z?: number);
  1258. /**
  1259. * Creates a string representation of the Vector3
  1260. * @returns a string with the Vector3 coordinates.
  1261. */
  1262. toString(): string;
  1263. /**
  1264. * Gets the class name
  1265. * @returns the string "Vector3"
  1266. */
  1267. getClassName(): string;
  1268. /**
  1269. * Creates the Vector3 hash code
  1270. * @returns a number which tends to be unique between Vector3 instances
  1271. */
  1272. getHashCode(): number;
  1273. /**
  1274. * Creates an array containing three elements : the coordinates of the Vector3
  1275. * @returns a new array of numbers
  1276. */
  1277. asArray(): number[];
  1278. /**
  1279. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1280. * @param array defines the destination array
  1281. * @param index defines the offset in the destination array
  1282. * @returns the current Vector3
  1283. */
  1284. toArray(array: FloatArray, index?: number): Vector3;
  1285. /**
  1286. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1287. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1288. */
  1289. toQuaternion(): Quaternion;
  1290. /**
  1291. * Adds the given vector to the current Vector3
  1292. * @param otherVector defines the second operand
  1293. * @returns the current updated Vector3
  1294. */
  1295. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1296. /**
  1297. * Adds the given coordinates to the current Vector3
  1298. * @param x defines the x coordinate of the operand
  1299. * @param y defines the y coordinate of the operand
  1300. * @param z defines the z coordinate of the operand
  1301. * @returns the current updated Vector3
  1302. */
  1303. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1304. /**
  1305. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1306. * @param otherVector defines the second operand
  1307. * @returns the resulting Vector3
  1308. */
  1309. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1310. /**
  1311. * Adds the current Vector3 to the given one 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. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1317. /**
  1318. * Subtract the given vector from the current Vector3
  1319. * @param otherVector defines the second operand
  1320. * @returns the current updated Vector3
  1321. */
  1322. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1323. /**
  1324. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1325. * @param otherVector defines the second operand
  1326. * @returns the resulting Vector3
  1327. */
  1328. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1329. /**
  1330. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1331. * @param otherVector defines the second operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1336. /**
  1337. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1338. * @param x defines the x coordinate of the operand
  1339. * @param y defines the y coordinate of the operand
  1340. * @param z defines the z coordinate of the operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1344. /**
  1345. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1346. * @param x defines the x coordinate of the operand
  1347. * @param y defines the y coordinate of the operand
  1348. * @param z defines the z coordinate of the operand
  1349. * @param result defines the Vector3 object where to store the result
  1350. * @returns the current Vector3
  1351. */
  1352. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1353. /**
  1354. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1355. * @returns a new Vector3
  1356. */
  1357. negate(): Vector3;
  1358. /**
  1359. * Multiplies the Vector3 coordinates by the float "scale"
  1360. * @param scale defines the multiplier factor
  1361. * @returns the current updated Vector3
  1362. */
  1363. scaleInPlace(scale: number): Vector3;
  1364. /**
  1365. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1366. * @param scale defines the multiplier factor
  1367. * @returns a new Vector3
  1368. */
  1369. scale(scale: number): Vector3;
  1370. /**
  1371. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1372. * @param scale defines the multiplier factor
  1373. * @param result defines the Vector3 object where to store the result
  1374. * @returns the current Vector3
  1375. */
  1376. scaleToRef(scale: number, result: Vector3): Vector3;
  1377. /**
  1378. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1379. * @param scale defines the scale factor
  1380. * @param result defines the Vector3 object where to store the result
  1381. * @returns the unmodified current Vector3
  1382. */
  1383. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1384. /**
  1385. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1386. * @param otherVector defines the second operand
  1387. * @returns true if both vectors are equals
  1388. */
  1389. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1390. /**
  1391. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1392. * @param otherVector defines the second operand
  1393. * @param epsilon defines the minimal distance to define values as equals
  1394. * @returns true if both vectors are distant less than epsilon
  1395. */
  1396. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1397. /**
  1398. * Returns true if the current Vector3 coordinates equals the given floats
  1399. * @param x defines the x coordinate of the operand
  1400. * @param y defines the y coordinate of the operand
  1401. * @param z defines the z coordinate of the operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equalsToFloats(x: number, y: number, z: number): boolean;
  1405. /**
  1406. * Multiplies the current Vector3 coordinates by the given ones
  1407. * @param otherVector defines the second operand
  1408. * @returns the current updated Vector3
  1409. */
  1410. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1411. /**
  1412. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1413. * @param otherVector defines the second operand
  1414. * @returns the new Vector3
  1415. */
  1416. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1417. /**
  1418. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1419. * @param otherVector defines the second operand
  1420. * @param result defines the Vector3 object where to store the result
  1421. * @returns the current Vector3
  1422. */
  1423. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1424. /**
  1425. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1426. * @param x defines the x coordinate of the operand
  1427. * @param y defines the y coordinate of the operand
  1428. * @param z defines the z coordinate of the operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1432. /**
  1433. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1434. * @param otherVector defines the second operand
  1435. * @returns the new Vector3
  1436. */
  1437. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1438. /**
  1439. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1440. * @param otherVector defines the second operand
  1441. * @param result defines the Vector3 object where to store the result
  1442. * @returns the current Vector3
  1443. */
  1444. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1445. /**
  1446. * Divides the current Vector3 coordinates by the given ones.
  1447. * @param otherVector defines the second operand
  1448. * @returns the current updated Vector3
  1449. */
  1450. divideInPlace(otherVector: Vector3): Vector3;
  1451. /**
  1452. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1453. * @param other defines the second operand
  1454. * @returns the current updated Vector3
  1455. */
  1456. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1457. /**
  1458. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1459. * @param other defines the second operand
  1460. * @returns the current updated Vector3
  1461. */
  1462. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1463. /**
  1464. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1465. * @param x defines the x coordinate of the operand
  1466. * @param y defines the y coordinate of the operand
  1467. * @param z defines the z coordinate of the operand
  1468. * @returns the current updated Vector3
  1469. */
  1470. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1471. /**
  1472. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1473. * @param x defines the x coordinate of the operand
  1474. * @param y defines the y coordinate of the operand
  1475. * @param z defines the z coordinate of the operand
  1476. * @returns the current updated Vector3
  1477. */
  1478. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1479. /**
  1480. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1481. * Check if is non uniform within a certain amount of decimal places to account for this
  1482. * @param epsilon the amount the values can differ
  1483. * @returns if the the vector is non uniform to a certain number of decimal places
  1484. */
  1485. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1486. /**
  1487. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1488. */
  1489. readonly isNonUniform: boolean;
  1490. /**
  1491. * Gets a new Vector3 from current Vector3 floored values
  1492. * @returns a new Vector3
  1493. */
  1494. floor(): Vector3;
  1495. /**
  1496. * Gets a new Vector3 from current Vector3 floored values
  1497. * @returns a new Vector3
  1498. */
  1499. fract(): Vector3;
  1500. /**
  1501. * Gets the length of the Vector3
  1502. * @returns the length of the Vecto3
  1503. */
  1504. length(): number;
  1505. /**
  1506. * Gets the squared length of the Vector3
  1507. * @returns squared length of the Vector3
  1508. */
  1509. lengthSquared(): number;
  1510. /**
  1511. * Normalize the current Vector3.
  1512. * Please note that this is an in place operation.
  1513. * @returns the current updated Vector3
  1514. */
  1515. normalize(): Vector3;
  1516. /**
  1517. * Reorders the x y z properties of the vector in place
  1518. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1519. * @returns the current updated vector
  1520. */
  1521. reorderInPlace(order: string): this;
  1522. /**
  1523. * Rotates the vector around 0,0,0 by a quaternion
  1524. * @param quaternion the rotation quaternion
  1525. * @param result vector to store the result
  1526. * @returns the resulting vector
  1527. */
  1528. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1529. /**
  1530. * Rotates a vector around a given point
  1531. * @param quaternion the rotation quaternion
  1532. * @param point the point to rotate around
  1533. * @param result vector to store the result
  1534. * @returns the resulting vector
  1535. */
  1536. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1537. /**
  1538. * Normalize the current Vector3 with the given input length.
  1539. * Please note that this is an in place operation.
  1540. * @param len the length of the vector
  1541. * @returns the current updated Vector3
  1542. */
  1543. normalizeFromLength(len: number): Vector3;
  1544. /**
  1545. * Normalize the current Vector3 to a new vector
  1546. * @returns the new Vector3
  1547. */
  1548. normalizeToNew(): Vector3;
  1549. /**
  1550. * Normalize the current Vector3 to the reference
  1551. * @param reference define the Vector3 to update
  1552. * @returns the updated Vector3
  1553. */
  1554. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1555. /**
  1556. * Creates a new Vector3 copied from the current Vector3
  1557. * @returns the new Vector3
  1558. */
  1559. clone(): Vector3;
  1560. /**
  1561. * Copies the given vector coordinates to the current Vector3 ones
  1562. * @param source defines the source Vector3
  1563. * @returns the current updated Vector3
  1564. */
  1565. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1566. /**
  1567. * Copies the given floats to the current Vector3 coordinates
  1568. * @param x defines the x coordinate of the operand
  1569. * @param y defines the y coordinate of the operand
  1570. * @param z defines the z coordinate of the operand
  1571. * @returns the current updated Vector3
  1572. */
  1573. copyFromFloats(x: number, y: number, z: number): Vector3;
  1574. /**
  1575. * Copies the given floats to the current Vector3 coordinates
  1576. * @param x defines the x coordinate of the operand
  1577. * @param y defines the y coordinate of the operand
  1578. * @param z defines the z coordinate of the operand
  1579. * @returns the current updated Vector3
  1580. */
  1581. set(x: number, y: number, z: number): Vector3;
  1582. /**
  1583. * Copies the given float to the current Vector3 coordinates
  1584. * @param v defines the x, y and z coordinates of the operand
  1585. * @returns the current updated Vector3
  1586. */
  1587. setAll(v: number): Vector3;
  1588. /**
  1589. * Get the clip factor between two vectors
  1590. * @param vector0 defines the first operand
  1591. * @param vector1 defines the second operand
  1592. * @param axis defines the axis to use
  1593. * @param size defines the size along the axis
  1594. * @returns the clip factor
  1595. */
  1596. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1597. /**
  1598. * Get angle between two vectors
  1599. * @param vector0 angle between vector0 and vector1
  1600. * @param vector1 angle between vector0 and vector1
  1601. * @param normal direction of the normal
  1602. * @return the angle between vector0 and vector1
  1603. */
  1604. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1605. /**
  1606. * Returns a new Vector3 set from the index "offset" of the given array
  1607. * @param array defines the source array
  1608. * @param offset defines the offset in the source array
  1609. * @returns the new Vector3
  1610. */
  1611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1612. /**
  1613. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1614. * This function is deprecated. Use FromArray instead
  1615. * @param array defines the source array
  1616. * @param offset defines the offset in the source array
  1617. * @returns the new Vector3
  1618. */
  1619. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1620. /**
  1621. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1622. * @param array defines the source array
  1623. * @param offset defines the offset in the source array
  1624. * @param result defines the Vector3 where to store the result
  1625. */
  1626. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1627. /**
  1628. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1629. * This function is deprecated. Use FromArrayToRef instead.
  1630. * @param array defines the source array
  1631. * @param offset defines the offset in the source array
  1632. * @param result defines the Vector3 where to store the result
  1633. */
  1634. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1635. /**
  1636. * Sets the given vector "result" with the given floats.
  1637. * @param x defines the x coordinate of the source
  1638. * @param y defines the y coordinate of the source
  1639. * @param z defines the z coordinate of the source
  1640. * @param result defines the Vector3 where to store the result
  1641. */
  1642. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1643. /**
  1644. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1645. * @returns a new empty Vector3
  1646. */
  1647. static Zero(): Vector3;
  1648. /**
  1649. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1650. * @returns a new unit Vector3
  1651. */
  1652. static One(): Vector3;
  1653. /**
  1654. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1655. * @returns a new up Vector3
  1656. */
  1657. static Up(): Vector3;
  1658. /**
  1659. * Gets a up Vector3 that must not be updated
  1660. */
  1661. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1662. /**
  1663. * Gets a zero Vector3 that must not be updated
  1664. */
  1665. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1666. /**
  1667. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1668. * @returns a new down Vector3
  1669. */
  1670. static Down(): Vector3;
  1671. /**
  1672. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1673. * @returns a new forward Vector3
  1674. */
  1675. static Forward(): Vector3;
  1676. /**
  1677. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1678. * @returns a new forward Vector3
  1679. */
  1680. static Backward(): Vector3;
  1681. /**
  1682. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1683. * @returns a new right Vector3
  1684. */
  1685. static Right(): Vector3;
  1686. /**
  1687. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1688. * @returns a new left Vector3
  1689. */
  1690. static Left(): Vector3;
  1691. /**
  1692. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1693. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1694. * @param vector defines the Vector3 to transform
  1695. * @param transformation defines the transformation matrix
  1696. * @returns the transformed Vector3
  1697. */
  1698. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1699. /**
  1700. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1701. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1702. * @param vector defines the Vector3 to transform
  1703. * @param transformation defines the transformation matrix
  1704. * @param result defines the Vector3 where to store the result
  1705. */
  1706. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1707. /**
  1708. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1709. * This method computes tranformed coordinates only, not transformed direction vectors
  1710. * @param x define the x coordinate of the source vector
  1711. * @param y define the y coordinate of the source vector
  1712. * @param z define the z coordinate of the source vector
  1713. * @param transformation defines the transformation matrix
  1714. * @param result defines the Vector3 where to store the result
  1715. */
  1716. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1717. /**
  1718. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1719. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1720. * @param vector defines the Vector3 to transform
  1721. * @param transformation defines the transformation matrix
  1722. * @returns the new Vector3
  1723. */
  1724. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1725. /**
  1726. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1727. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1728. * @param vector defines the Vector3 to transform
  1729. * @param transformation defines the transformation matrix
  1730. * @param result defines the Vector3 where to store the result
  1731. */
  1732. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1733. /**
  1734. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1735. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1736. * @param x define the x coordinate of the source vector
  1737. * @param y define the y coordinate of the source vector
  1738. * @param z define the z coordinate of the source vector
  1739. * @param transformation defines the transformation matrix
  1740. * @param result defines the Vector3 where to store the result
  1741. */
  1742. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1743. /**
  1744. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1745. * @param value1 defines the first control point
  1746. * @param value2 defines the second control point
  1747. * @param value3 defines the third control point
  1748. * @param value4 defines the fourth control point
  1749. * @param amount defines the amount on the spline to use
  1750. * @returns the new Vector3
  1751. */
  1752. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1753. /**
  1754. * 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"
  1755. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1756. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1757. * @param value defines the current value
  1758. * @param min defines the lower range value
  1759. * @param max defines the upper range value
  1760. * @returns the new Vector3
  1761. */
  1762. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1763. /**
  1764. * 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"
  1765. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1766. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1767. * @param value defines the current value
  1768. * @param min defines the lower range value
  1769. * @param max defines the upper range value
  1770. * @param result defines the Vector3 where to store the result
  1771. */
  1772. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1773. /**
  1774. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1775. * @param value1 defines the first control point
  1776. * @param tangent1 defines the first tangent vector
  1777. * @param value2 defines the second control point
  1778. * @param tangent2 defines the second tangent vector
  1779. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1780. * @returns the new Vector3
  1781. */
  1782. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1783. /**
  1784. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1785. * @param start defines the start value
  1786. * @param end defines the end value
  1787. * @param amount max defines amount between both (between 0 and 1)
  1788. * @returns the new Vector3
  1789. */
  1790. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1791. /**
  1792. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1793. * @param start defines the start value
  1794. * @param end defines the end value
  1795. * @param amount max defines amount between both (between 0 and 1)
  1796. * @param result defines the Vector3 where to store the result
  1797. */
  1798. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1799. /**
  1800. * Returns the dot product (float) between the vectors "left" and "right"
  1801. * @param left defines the left operand
  1802. * @param right defines the right operand
  1803. * @returns the dot product
  1804. */
  1805. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1806. /**
  1807. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1808. * The cross product is then orthogonal to both "left" and "right"
  1809. * @param left defines the left operand
  1810. * @param right defines the right operand
  1811. * @returns the cross product
  1812. */
  1813. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1814. /**
  1815. * Sets the given vector "result" with the cross product of "left" and "right"
  1816. * The cross product is then orthogonal to both "left" and "right"
  1817. * @param left defines the left operand
  1818. * @param right defines the right operand
  1819. * @param result defines the Vector3 where to store the result
  1820. */
  1821. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1822. /**
  1823. * Returns a new Vector3 as the normalization of the given vector
  1824. * @param vector defines the Vector3 to normalize
  1825. * @returns the new Vector3
  1826. */
  1827. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1828. /**
  1829. * Sets the given vector "result" with the normalization of the given first vector
  1830. * @param vector defines the Vector3 to normalize
  1831. * @param result defines the Vector3 where to store the result
  1832. */
  1833. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1834. /**
  1835. * Project a Vector3 onto screen space
  1836. * @param vector defines the Vector3 to project
  1837. * @param world defines the world matrix to use
  1838. * @param transform defines the transform (view x projection) matrix to use
  1839. * @param viewport defines the screen viewport to use
  1840. * @returns the new Vector3
  1841. */
  1842. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1843. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1844. /**
  1845. * Unproject from screen space to object space
  1846. * @param source defines the screen space Vector3 to use
  1847. * @param viewportWidth defines the current width of the viewport
  1848. * @param viewportHeight defines the current height of the viewport
  1849. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1850. * @param transform defines the transform (view x projection) matrix to use
  1851. * @returns the new Vector3
  1852. */
  1853. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1854. /**
  1855. * Unproject from screen space to object space
  1856. * @param source defines the screen space Vector3 to use
  1857. * @param viewportWidth defines the current width of the viewport
  1858. * @param viewportHeight defines the current height of the viewport
  1859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1860. * @param view defines the view matrix to use
  1861. * @param projection defines the projection matrix to use
  1862. * @returns the new Vector3
  1863. */
  1864. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1865. /**
  1866. * Unproject from screen space to object space
  1867. * @param source defines the screen space Vector3 to use
  1868. * @param viewportWidth defines the current width of the viewport
  1869. * @param viewportHeight defines the current height of the viewport
  1870. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1871. * @param view defines the view matrix to use
  1872. * @param projection defines the projection matrix to use
  1873. * @param result defines the Vector3 where to store the result
  1874. */
  1875. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1876. /**
  1877. * Unproject from screen space to object space
  1878. * @param sourceX defines the screen space x coordinate to use
  1879. * @param sourceY defines the screen space y coordinate to use
  1880. * @param sourceZ defines the screen space z coordinate to use
  1881. * @param viewportWidth defines the current width of the viewport
  1882. * @param viewportHeight defines the current height of the viewport
  1883. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1884. * @param view defines the view matrix to use
  1885. * @param projection defines the projection matrix to use
  1886. * @param result defines the Vector3 where to store the result
  1887. */
  1888. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1889. /**
  1890. * Gets the minimal coordinate values between two Vector3
  1891. * @param left defines the first operand
  1892. * @param right defines the second operand
  1893. * @returns the new Vector3
  1894. */
  1895. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1896. /**
  1897. * Gets the maximal coordinate values between two Vector3
  1898. * @param left defines the first operand
  1899. * @param right defines the second operand
  1900. * @returns the new Vector3
  1901. */
  1902. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1903. /**
  1904. * Returns the distance between the vectors "value1" and "value2"
  1905. * @param value1 defines the first operand
  1906. * @param value2 defines the second operand
  1907. * @returns the distance
  1908. */
  1909. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1910. /**
  1911. * Returns the squared distance between the vectors "value1" and "value2"
  1912. * @param value1 defines the first operand
  1913. * @param value2 defines the second operand
  1914. * @returns the squared distance
  1915. */
  1916. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1917. /**
  1918. * Returns a new Vector3 located at the center between "value1" and "value2"
  1919. * @param value1 defines the first operand
  1920. * @param value2 defines the second operand
  1921. * @returns the new Vector3
  1922. */
  1923. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1924. /**
  1925. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1926. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1927. * to something in order to rotate it from its local system to the given target system
  1928. * Note: axis1, axis2 and axis3 are normalized during this operation
  1929. * @param axis1 defines the first axis
  1930. * @param axis2 defines the second axis
  1931. * @param axis3 defines the third axis
  1932. * @returns a new Vector3
  1933. */
  1934. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1935. /**
  1936. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1937. * @param axis1 defines the first axis
  1938. * @param axis2 defines the second axis
  1939. * @param axis3 defines the third axis
  1940. * @param ref defines the Vector3 where to store the result
  1941. */
  1942. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1943. }
  1944. /**
  1945. * Vector4 class created for EulerAngle class conversion to Quaternion
  1946. */
  1947. export class Vector4 {
  1948. /** x value of the vector */
  1949. x: number;
  1950. /** y value of the vector */
  1951. y: number;
  1952. /** z value of the vector */
  1953. z: number;
  1954. /** w value of the vector */
  1955. w: number;
  1956. /**
  1957. * Creates a Vector4 object from the given floats.
  1958. * @param x x value of the vector
  1959. * @param y y value of the vector
  1960. * @param z z value of the vector
  1961. * @param w w value of the vector
  1962. */
  1963. constructor(
  1964. /** x value of the vector */
  1965. x: number,
  1966. /** y value of the vector */
  1967. y: number,
  1968. /** z value of the vector */
  1969. z: number,
  1970. /** w value of the vector */
  1971. w: number);
  1972. /**
  1973. * Returns the string with the Vector4 coordinates.
  1974. * @returns a string containing all the vector values
  1975. */
  1976. toString(): string;
  1977. /**
  1978. * Returns the string "Vector4".
  1979. * @returns "Vector4"
  1980. */
  1981. getClassName(): string;
  1982. /**
  1983. * Returns the Vector4 hash code.
  1984. * @returns a unique hash code
  1985. */
  1986. getHashCode(): number;
  1987. /**
  1988. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1989. * @returns the resulting array
  1990. */
  1991. asArray(): number[];
  1992. /**
  1993. * Populates the given array from the given index with the Vector4 coordinates.
  1994. * @param array array to populate
  1995. * @param index index of the array to start at (default: 0)
  1996. * @returns the Vector4.
  1997. */
  1998. toArray(array: FloatArray, index?: number): Vector4;
  1999. /**
  2000. * Adds the given vector to the current Vector4.
  2001. * @param otherVector the vector to add
  2002. * @returns the updated Vector4.
  2003. */
  2004. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2005. /**
  2006. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2007. * @param otherVector the vector to add
  2008. * @returns the resulting vector
  2009. */
  2010. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2011. /**
  2012. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2013. * @param otherVector the vector to add
  2014. * @param result the vector to store the result
  2015. * @returns the current Vector4.
  2016. */
  2017. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2018. /**
  2019. * Subtract in place the given vector from the current Vector4.
  2020. * @param otherVector the vector to subtract
  2021. * @returns the updated Vector4.
  2022. */
  2023. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2024. /**
  2025. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2026. * @param otherVector the vector to add
  2027. * @returns the new vector with the result
  2028. */
  2029. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2030. /**
  2031. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2032. * @param otherVector the vector to subtract
  2033. * @param result the vector to store the result
  2034. * @returns the current Vector4.
  2035. */
  2036. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2037. /**
  2038. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2039. */
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. * @param x value to subtract
  2043. * @param y value to subtract
  2044. * @param z value to subtract
  2045. * @param w value to subtract
  2046. * @returns new vector containing the result
  2047. */
  2048. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2049. /**
  2050. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2051. * @param x value to subtract
  2052. * @param y value to subtract
  2053. * @param z value to subtract
  2054. * @param w value to subtract
  2055. * @param result the vector to store the result in
  2056. * @returns the current Vector4.
  2057. */
  2058. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2059. /**
  2060. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2061. * @returns a new vector with the negated values
  2062. */
  2063. negate(): Vector4;
  2064. /**
  2065. * Multiplies the current Vector4 coordinates by scale (float).
  2066. * @param scale the number to scale with
  2067. * @returns the updated Vector4.
  2068. */
  2069. scaleInPlace(scale: number): Vector4;
  2070. /**
  2071. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2072. * @param scale the number to scale with
  2073. * @returns a new vector with the result
  2074. */
  2075. scale(scale: number): Vector4;
  2076. /**
  2077. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2078. * @param scale the number to scale with
  2079. * @param result a vector to store the result in
  2080. * @returns the current Vector4.
  2081. */
  2082. scaleToRef(scale: number, result: Vector4): Vector4;
  2083. /**
  2084. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2085. * @param scale defines the scale factor
  2086. * @param result defines the Vector4 object where to store the result
  2087. * @returns the unmodified current Vector4
  2088. */
  2089. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2090. /**
  2091. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2092. * @param otherVector the vector to compare against
  2093. * @returns true if they are equal
  2094. */
  2095. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2096. /**
  2097. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2098. * @param otherVector vector to compare against
  2099. * @param epsilon (Default: very small number)
  2100. * @returns true if they are equal
  2101. */
  2102. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2103. /**
  2104. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2105. * @param x x value to compare against
  2106. * @param y y value to compare against
  2107. * @param z z value to compare against
  2108. * @param w w value to compare against
  2109. * @returns true if equal
  2110. */
  2111. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2112. /**
  2113. * Multiplies in place the current Vector4 by the given one.
  2114. * @param otherVector vector to multiple with
  2115. * @returns the updated Vector4.
  2116. */
  2117. multiplyInPlace(otherVector: Vector4): Vector4;
  2118. /**
  2119. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2120. * @param otherVector vector to multiple with
  2121. * @returns resulting new vector
  2122. */
  2123. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2124. /**
  2125. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2126. * @param otherVector vector to multiple with
  2127. * @param result vector to store the result
  2128. * @returns the current Vector4.
  2129. */
  2130. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2131. /**
  2132. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2133. * @param x x value multiply with
  2134. * @param y y value multiply with
  2135. * @param z z value multiply with
  2136. * @param w w value multiply with
  2137. * @returns resulting new vector
  2138. */
  2139. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2140. /**
  2141. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2142. * @param otherVector vector to devide with
  2143. * @returns resulting new vector
  2144. */
  2145. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2146. /**
  2147. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2148. * @param otherVector vector to devide with
  2149. * @param result vector to store the result
  2150. * @returns the current Vector4.
  2151. */
  2152. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2153. /**
  2154. * Divides the current Vector3 coordinates by the given ones.
  2155. * @param otherVector vector to devide with
  2156. * @returns the updated Vector3.
  2157. */
  2158. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2159. /**
  2160. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2161. * @param other defines the second operand
  2162. * @returns the current updated Vector4
  2163. */
  2164. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2165. /**
  2166. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2167. * @param other defines the second operand
  2168. * @returns the current updated Vector4
  2169. */
  2170. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2171. /**
  2172. * Gets a new Vector4 from current Vector4 floored values
  2173. * @returns a new Vector4
  2174. */
  2175. floor(): Vector4;
  2176. /**
  2177. * Gets a new Vector4 from current Vector3 floored values
  2178. * @returns a new Vector4
  2179. */
  2180. fract(): Vector4;
  2181. /**
  2182. * Returns the Vector4 length (float).
  2183. * @returns the length
  2184. */
  2185. length(): number;
  2186. /**
  2187. * Returns the Vector4 squared length (float).
  2188. * @returns the length squared
  2189. */
  2190. lengthSquared(): number;
  2191. /**
  2192. * Normalizes in place the Vector4.
  2193. * @returns the updated Vector4.
  2194. */
  2195. normalize(): Vector4;
  2196. /**
  2197. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2198. * @returns this converted to a new vector3
  2199. */
  2200. toVector3(): Vector3;
  2201. /**
  2202. * Returns a new Vector4 copied from the current one.
  2203. * @returns the new cloned vector
  2204. */
  2205. clone(): Vector4;
  2206. /**
  2207. * Updates the current Vector4 with the given one coordinates.
  2208. * @param source the source vector to copy from
  2209. * @returns the updated Vector4.
  2210. */
  2211. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2212. /**
  2213. * Updates the current Vector4 coordinates with the given floats.
  2214. * @param x float to copy from
  2215. * @param y float to copy from
  2216. * @param z float to copy from
  2217. * @param w float to copy from
  2218. * @returns the updated Vector4.
  2219. */
  2220. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2221. /**
  2222. * Updates the current Vector4 coordinates with the given floats.
  2223. * @param x float to set from
  2224. * @param y float to set from
  2225. * @param z float to set from
  2226. * @param w float to set from
  2227. * @returns the updated Vector4.
  2228. */
  2229. set(x: number, y: number, z: number, w: number): Vector4;
  2230. /**
  2231. * Copies the given float to the current Vector3 coordinates
  2232. * @param v defines the x, y, z and w coordinates of the operand
  2233. * @returns the current updated Vector3
  2234. */
  2235. setAll(v: number): Vector4;
  2236. /**
  2237. * Returns a new Vector4 set from the starting index of the given array.
  2238. * @param array the array to pull values from
  2239. * @param offset the offset into the array to start at
  2240. * @returns the new vector
  2241. */
  2242. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2243. /**
  2244. * Updates the given vector "result" from the starting index of the given array.
  2245. * @param array the array to pull values from
  2246. * @param offset the offset into the array to start at
  2247. * @param result the vector to store the result in
  2248. */
  2249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2250. /**
  2251. * Updates the given vector "result" from the starting index of the given Float32Array.
  2252. * @param array the array to pull values from
  2253. * @param offset the offset into the array to start at
  2254. * @param result the vector to store the result in
  2255. */
  2256. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2257. /**
  2258. * Updates the given vector "result" coordinates from the given floats.
  2259. * @param x float to set from
  2260. * @param y float to set from
  2261. * @param z float to set from
  2262. * @param w float to set from
  2263. * @param result the vector to the floats in
  2264. */
  2265. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2266. /**
  2267. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2268. * @returns the new vector
  2269. */
  2270. static Zero(): Vector4;
  2271. /**
  2272. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2273. * @returns the new vector
  2274. */
  2275. static One(): Vector4;
  2276. /**
  2277. * Returns a new normalized Vector4 from the given one.
  2278. * @param vector the vector to normalize
  2279. * @returns the vector
  2280. */
  2281. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Updates the given vector "result" from the normalization of the given one.
  2284. * @param vector the vector to normalize
  2285. * @param result the vector to store the result in
  2286. */
  2287. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2288. /**
  2289. * Returns a vector with the minimum values from the left and right vectors
  2290. * @param left left vector to minimize
  2291. * @param right right vector to minimize
  2292. * @returns a new vector with the minimum of the left and right vector values
  2293. */
  2294. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2295. /**
  2296. * Returns a vector with the maximum values from the left and right vectors
  2297. * @param left left vector to maximize
  2298. * @param right right vector to maximize
  2299. * @returns a new vector with the maximum of the left and right vector values
  2300. */
  2301. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2302. /**
  2303. * Returns the distance (float) between the vectors "value1" and "value2".
  2304. * @param value1 value to calulate the distance between
  2305. * @param value2 value to calulate the distance between
  2306. * @return the distance between the two vectors
  2307. */
  2308. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2309. /**
  2310. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2311. * @param value1 value to calulate the distance between
  2312. * @param value2 value to calulate the distance between
  2313. * @return the distance between the two vectors squared
  2314. */
  2315. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2316. /**
  2317. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2318. * @param value1 value to calulate the center between
  2319. * @param value2 value to calulate the center between
  2320. * @return the center between the two vectors
  2321. */
  2322. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2323. /**
  2324. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2325. * This methods computes transformed normalized direction vectors only.
  2326. * @param vector the vector to transform
  2327. * @param transformation the transformation matrix to apply
  2328. * @returns the new vector
  2329. */
  2330. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2331. /**
  2332. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2333. * This methods computes transformed normalized direction vectors only.
  2334. * @param vector the vector to transform
  2335. * @param transformation the transformation matrix to apply
  2336. * @param result the vector to store the result in
  2337. */
  2338. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2339. /**
  2340. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2341. * This methods computes transformed normalized direction vectors only.
  2342. * @param x value to transform
  2343. * @param y value to transform
  2344. * @param z value to transform
  2345. * @param w value to transform
  2346. * @param transformation the transformation matrix to apply
  2347. * @param result the vector to store the results in
  2348. */
  2349. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2350. /**
  2351. * Creates a new Vector4 from a Vector3
  2352. * @param source defines the source data
  2353. * @param w defines the 4th component (default is 0)
  2354. * @returns a new Vector4
  2355. */
  2356. static FromVector3(source: Vector3, w?: number): Vector4;
  2357. }
  2358. /**
  2359. * Interface for the size containing width and height
  2360. */
  2361. export interface ISize {
  2362. /**
  2363. * Width
  2364. */
  2365. width: number;
  2366. /**
  2367. * Heighht
  2368. */
  2369. height: number;
  2370. }
  2371. /**
  2372. * Size containing widht and height
  2373. */
  2374. export class Size implements ISize {
  2375. /**
  2376. * Width
  2377. */
  2378. width: number;
  2379. /**
  2380. * Height
  2381. */
  2382. height: number;
  2383. /**
  2384. * Creates a Size object from the given width and height (floats).
  2385. * @param width width of the new size
  2386. * @param height height of the new size
  2387. */
  2388. constructor(width: number, height: number);
  2389. /**
  2390. * Returns a string with the Size width and height
  2391. * @returns a string with the Size width and height
  2392. */
  2393. toString(): string;
  2394. /**
  2395. * "Size"
  2396. * @returns the string "Size"
  2397. */
  2398. getClassName(): string;
  2399. /**
  2400. * Returns the Size hash code.
  2401. * @returns a hash code for a unique width and height
  2402. */
  2403. getHashCode(): number;
  2404. /**
  2405. * Updates the current size from the given one.
  2406. * @param src the given size
  2407. */
  2408. copyFrom(src: Size): void;
  2409. /**
  2410. * Updates in place the current Size from the given floats.
  2411. * @param width width of the new size
  2412. * @param height height of the new size
  2413. * @returns the updated Size.
  2414. */
  2415. copyFromFloats(width: number, height: number): Size;
  2416. /**
  2417. * Updates in place the current Size from the given floats.
  2418. * @param width width to set
  2419. * @param height height to set
  2420. * @returns the updated Size.
  2421. */
  2422. set(width: number, height: number): Size;
  2423. /**
  2424. * Multiplies the width and height by numbers
  2425. * @param w factor to multiple the width by
  2426. * @param h factor to multiple the height by
  2427. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2428. */
  2429. multiplyByFloats(w: number, h: number): Size;
  2430. /**
  2431. * Clones the size
  2432. * @returns a new Size copied from the given one.
  2433. */
  2434. clone(): Size;
  2435. /**
  2436. * True if the current Size and the given one width and height are strictly equal.
  2437. * @param other the other size to compare against
  2438. * @returns True if the current Size and the given one width and height are strictly equal.
  2439. */
  2440. equals(other: Size): boolean;
  2441. /**
  2442. * The surface of the Size : width * height (float).
  2443. */
  2444. readonly surface: number;
  2445. /**
  2446. * Create a new size of zero
  2447. * @returns a new Size set to (0.0, 0.0)
  2448. */
  2449. static Zero(): Size;
  2450. /**
  2451. * Sums the width and height of two sizes
  2452. * @param otherSize size to add to this size
  2453. * @returns a new Size set as the addition result of the current Size and the given one.
  2454. */
  2455. add(otherSize: Size): Size;
  2456. /**
  2457. * Subtracts the width and height of two
  2458. * @param otherSize size to subtract to this size
  2459. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2460. */
  2461. subtract(otherSize: Size): Size;
  2462. /**
  2463. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2464. * @param start starting size to lerp between
  2465. * @param end end size to lerp between
  2466. * @param amount amount to lerp between the start and end values
  2467. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2468. */
  2469. static Lerp(start: Size, end: Size, amount: number): Size;
  2470. }
  2471. /**
  2472. * Class used to store quaternion data
  2473. * @see https://en.wikipedia.org/wiki/Quaternion
  2474. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2475. */
  2476. export class Quaternion {
  2477. /** defines the first component (0 by default) */
  2478. x: number;
  2479. /** defines the second component (0 by default) */
  2480. y: number;
  2481. /** defines the third component (0 by default) */
  2482. z: number;
  2483. /** defines the fourth component (1.0 by default) */
  2484. w: number;
  2485. /**
  2486. * Creates a new Quaternion from the given floats
  2487. * @param x defines the first component (0 by default)
  2488. * @param y defines the second component (0 by default)
  2489. * @param z defines the third component (0 by default)
  2490. * @param w defines the fourth component (1.0 by default)
  2491. */
  2492. constructor(
  2493. /** defines the first component (0 by default) */
  2494. x?: number,
  2495. /** defines the second component (0 by default) */
  2496. y?: number,
  2497. /** defines the third component (0 by default) */
  2498. z?: number,
  2499. /** defines the fourth component (1.0 by default) */
  2500. w?: number);
  2501. /**
  2502. * Gets a string representation for the current quaternion
  2503. * @returns a string with the Quaternion coordinates
  2504. */
  2505. toString(): string;
  2506. /**
  2507. * Gets the class name of the quaternion
  2508. * @returns the string "Quaternion"
  2509. */
  2510. getClassName(): string;
  2511. /**
  2512. * Gets a hash code for this quaternion
  2513. * @returns the quaternion hash code
  2514. */
  2515. getHashCode(): number;
  2516. /**
  2517. * Copy the quaternion to an array
  2518. * @returns a new array populated with 4 elements from the quaternion coordinates
  2519. */
  2520. asArray(): number[];
  2521. /**
  2522. * Check if two quaternions are equals
  2523. * @param otherQuaternion defines the second operand
  2524. * @return true if the current quaternion and the given one coordinates are strictly equals
  2525. */
  2526. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2527. /**
  2528. * Clone the current quaternion
  2529. * @returns a new quaternion copied from the current one
  2530. */
  2531. clone(): Quaternion;
  2532. /**
  2533. * Copy a quaternion to the current one
  2534. * @param other defines the other quaternion
  2535. * @returns the updated current quaternion
  2536. */
  2537. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2538. /**
  2539. * Updates the current quaternion with the given float coordinates
  2540. * @param x defines the x coordinate
  2541. * @param y defines the y coordinate
  2542. * @param z defines the z coordinate
  2543. * @param w defines the w coordinate
  2544. * @returns the updated current quaternion
  2545. */
  2546. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2547. /**
  2548. * Updates the current quaternion from the given float coordinates
  2549. * @param x defines the x coordinate
  2550. * @param y defines the y coordinate
  2551. * @param z defines the z coordinate
  2552. * @param w defines the w coordinate
  2553. * @returns the updated current quaternion
  2554. */
  2555. set(x: number, y: number, z: number, w: number): Quaternion;
  2556. /**
  2557. * Adds two quaternions
  2558. * @param other defines the second operand
  2559. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2560. */
  2561. add(other: DeepImmutable<Quaternion>): Quaternion;
  2562. /**
  2563. * Add a quaternion to the current one
  2564. * @param other defines the quaternion to add
  2565. * @returns the current quaternion
  2566. */
  2567. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2568. /**
  2569. * Subtract two quaternions
  2570. * @param other defines the second operand
  2571. * @returns a new quaternion as the subtraction result of the given one from the current one
  2572. */
  2573. subtract(other: Quaternion): Quaternion;
  2574. /**
  2575. * Multiplies the current quaternion by a scale factor
  2576. * @param value defines the scale factor
  2577. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2578. */
  2579. scale(value: number): Quaternion;
  2580. /**
  2581. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2582. * @param scale defines the scale factor
  2583. * @param result defines the Quaternion object where to store the result
  2584. * @returns the unmodified current quaternion
  2585. */
  2586. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2587. /**
  2588. * Multiplies in place the current quaternion by a scale factor
  2589. * @param value defines the scale factor
  2590. * @returns the current modified quaternion
  2591. */
  2592. scaleInPlace(value: number): Quaternion;
  2593. /**
  2594. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2595. * @param scale defines the scale factor
  2596. * @param result defines the Quaternion object where to store the result
  2597. * @returns the unmodified current quaternion
  2598. */
  2599. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2600. /**
  2601. * Multiplies two quaternions
  2602. * @param q1 defines the second operand
  2603. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2604. */
  2605. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2606. /**
  2607. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2608. * @param q1 defines the second operand
  2609. * @param result defines the target quaternion
  2610. * @returns the current quaternion
  2611. */
  2612. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2613. /**
  2614. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2615. * @param q1 defines the second operand
  2616. * @returns the currentupdated quaternion
  2617. */
  2618. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2619. /**
  2620. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2621. * @param ref defines the target quaternion
  2622. * @returns the current quaternion
  2623. */
  2624. conjugateToRef(ref: Quaternion): Quaternion;
  2625. /**
  2626. * Conjugates in place (1-q) the current quaternion
  2627. * @returns the current updated quaternion
  2628. */
  2629. conjugateInPlace(): Quaternion;
  2630. /**
  2631. * Conjugates in place (1-q) the current quaternion
  2632. * @returns a new quaternion
  2633. */
  2634. conjugate(): Quaternion;
  2635. /**
  2636. * Gets length of current quaternion
  2637. * @returns the quaternion length (float)
  2638. */
  2639. length(): number;
  2640. /**
  2641. * Normalize in place the current quaternion
  2642. * @returns the current updated quaternion
  2643. */
  2644. normalize(): Quaternion;
  2645. /**
  2646. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2647. * @param order is a reserved parameter and is ignore for now
  2648. * @returns a new Vector3 containing the Euler angles
  2649. */
  2650. toEulerAngles(order?: string): Vector3;
  2651. /**
  2652. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2653. * @param result defines the vector which will be filled with the Euler angles
  2654. * @param order is a reserved parameter and is ignore for now
  2655. * @returns the current unchanged quaternion
  2656. */
  2657. toEulerAnglesToRef(result: Vector3): Quaternion;
  2658. /**
  2659. * Updates the given rotation matrix with the current quaternion values
  2660. * @param result defines the target matrix
  2661. * @returns the current unchanged quaternion
  2662. */
  2663. toRotationMatrix(result: Matrix): Quaternion;
  2664. /**
  2665. * Updates the current quaternion from the given rotation matrix values
  2666. * @param matrix defines the source matrix
  2667. * @returns the current updated quaternion
  2668. */
  2669. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2670. /**
  2671. * Creates a new quaternion from a rotation matrix
  2672. * @param matrix defines the source matrix
  2673. * @returns a new quaternion created from the given rotation matrix values
  2674. */
  2675. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2676. /**
  2677. * Updates the given quaternion with the given rotation matrix values
  2678. * @param matrix defines the source matrix
  2679. * @param result defines the target quaternion
  2680. */
  2681. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2682. /**
  2683. * Returns the dot product (float) between the quaternions "left" and "right"
  2684. * @param left defines the left operand
  2685. * @param right defines the right operand
  2686. * @returns the dot product
  2687. */
  2688. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2689. /**
  2690. * Checks if the two quaternions are close to each other
  2691. * @param quat0 defines the first quaternion to check
  2692. * @param quat1 defines the second quaternion to check
  2693. * @returns true if the two quaternions are close to each other
  2694. */
  2695. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2696. /**
  2697. * Creates an empty quaternion
  2698. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2699. */
  2700. static Zero(): Quaternion;
  2701. /**
  2702. * Inverse a given quaternion
  2703. * @param q defines the source quaternion
  2704. * @returns a new quaternion as the inverted current quaternion
  2705. */
  2706. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2707. /**
  2708. * Inverse a given quaternion
  2709. * @param q defines the source quaternion
  2710. * @param result the quaternion the result will be stored in
  2711. * @returns the result quaternion
  2712. */
  2713. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2714. /**
  2715. * Creates an identity quaternion
  2716. * @returns the identity quaternion
  2717. */
  2718. static Identity(): Quaternion;
  2719. /**
  2720. * Gets a boolean indicating if the given quaternion is identity
  2721. * @param quaternion defines the quaternion to check
  2722. * @returns true if the quaternion is identity
  2723. */
  2724. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2725. /**
  2726. * Creates a quaternion from a rotation around an axis
  2727. * @param axis defines the axis to use
  2728. * @param angle defines the angle to use
  2729. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2730. */
  2731. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2732. /**
  2733. * Creates a rotation around an axis and stores it into the given quaternion
  2734. * @param axis defines the axis to use
  2735. * @param angle defines the angle to use
  2736. * @param result defines the target quaternion
  2737. * @returns the target quaternion
  2738. */
  2739. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2740. /**
  2741. * Creates a new quaternion from data stored into an array
  2742. * @param array defines the data source
  2743. * @param offset defines the offset in the source array where the data starts
  2744. * @returns a new quaternion
  2745. */
  2746. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2747. /**
  2748. * Create a quaternion from Euler rotation angles
  2749. * @param x Pitch
  2750. * @param y Yaw
  2751. * @param z Roll
  2752. * @returns the new Quaternion
  2753. */
  2754. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2755. /**
  2756. * Updates a quaternion from Euler rotation angles
  2757. * @param x Pitch
  2758. * @param y Yaw
  2759. * @param z Roll
  2760. * @param result the quaternion to store the result
  2761. * @returns the updated quaternion
  2762. */
  2763. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2764. /**
  2765. * Create a quaternion from Euler rotation vector
  2766. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2767. * @returns the new Quaternion
  2768. */
  2769. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2770. /**
  2771. * Updates a quaternion from Euler rotation vector
  2772. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2773. * @param result the quaternion to store the result
  2774. * @returns the updated quaternion
  2775. */
  2776. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2777. /**
  2778. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2779. * @param yaw defines the rotation around Y axis
  2780. * @param pitch defines the rotation around X axis
  2781. * @param roll defines the rotation around Z axis
  2782. * @returns the new quaternion
  2783. */
  2784. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2785. /**
  2786. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2787. * @param yaw defines the rotation around Y axis
  2788. * @param pitch defines the rotation around X axis
  2789. * @param roll defines the rotation around Z axis
  2790. * @param result defines the target quaternion
  2791. */
  2792. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2793. /**
  2794. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2795. * @param alpha defines the rotation around first axis
  2796. * @param beta defines the rotation around second axis
  2797. * @param gamma defines the rotation around third axis
  2798. * @returns the new quaternion
  2799. */
  2800. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2801. /**
  2802. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2803. * @param alpha defines the rotation around first axis
  2804. * @param beta defines the rotation around second axis
  2805. * @param gamma defines the rotation around third axis
  2806. * @param result defines the target quaternion
  2807. */
  2808. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2809. /**
  2810. * 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)
  2811. * @param axis1 defines the first axis
  2812. * @param axis2 defines the second axis
  2813. * @param axis3 defines the third axis
  2814. * @returns the new quaternion
  2815. */
  2816. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2817. /**
  2818. * 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
  2819. * @param axis1 defines the first axis
  2820. * @param axis2 defines the second axis
  2821. * @param axis3 defines the third axis
  2822. * @param ref defines the target quaternion
  2823. */
  2824. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2825. /**
  2826. * Interpolates between two quaternions
  2827. * @param left defines first quaternion
  2828. * @param right defines second quaternion
  2829. * @param amount defines the gradient to use
  2830. * @returns the new interpolated quaternion
  2831. */
  2832. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2833. /**
  2834. * Interpolates between two quaternions and stores it into a target quaternion
  2835. * @param left defines first quaternion
  2836. * @param right defines second quaternion
  2837. * @param amount defines the gradient to use
  2838. * @param result defines the target quaternion
  2839. */
  2840. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2841. /**
  2842. * Interpolate between two quaternions using Hermite interpolation
  2843. * @param value1 defines first quaternion
  2844. * @param tangent1 defines the incoming tangent
  2845. * @param value2 defines second quaternion
  2846. * @param tangent2 defines the outgoing tangent
  2847. * @param amount defines the target quaternion
  2848. * @returns the new interpolated quaternion
  2849. */
  2850. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2851. }
  2852. /**
  2853. * Class used to store matrix data (4x4)
  2854. */
  2855. export class Matrix {
  2856. private static _updateFlagSeed;
  2857. private static _identityReadOnly;
  2858. private _isIdentity;
  2859. private _isIdentityDirty;
  2860. private _isIdentity3x2;
  2861. private _isIdentity3x2Dirty;
  2862. /**
  2863. * Gets the update flag of the matrix which is an unique number for the matrix.
  2864. * It will be incremented every time the matrix data change.
  2865. * You can use it to speed the comparison between two versions of the same matrix.
  2866. */
  2867. updateFlag: number;
  2868. private readonly _m;
  2869. /**
  2870. * Gets the internal data of the matrix
  2871. */
  2872. readonly m: DeepImmutable<Float32Array>;
  2873. /** @hidden */ private _markAsUpdated(): void;
  2874. /** @hidden */
  2875. private _updateIdentityStatus;
  2876. /**
  2877. * Creates an empty matrix (filled with zeros)
  2878. */
  2879. constructor();
  2880. /**
  2881. * Check if the current matrix is identity
  2882. * @returns true is the matrix is the identity matrix
  2883. */
  2884. isIdentity(): boolean;
  2885. /**
  2886. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2887. * @returns true is the matrix is the identity matrix
  2888. */
  2889. isIdentityAs3x2(): boolean;
  2890. /**
  2891. * Gets the determinant of the matrix
  2892. * @returns the matrix determinant
  2893. */
  2894. determinant(): number;
  2895. /**
  2896. * Returns the matrix as a Float32Array
  2897. * @returns the matrix underlying array
  2898. */
  2899. toArray(): DeepImmutable<Float32Array>;
  2900. /**
  2901. * Returns the matrix as a Float32Array
  2902. * @returns the matrix underlying array.
  2903. */
  2904. asArray(): DeepImmutable<Float32Array>;
  2905. /**
  2906. * Inverts the current matrix in place
  2907. * @returns the current inverted matrix
  2908. */
  2909. invert(): Matrix;
  2910. /**
  2911. * Sets all the matrix elements to zero
  2912. * @returns the current matrix
  2913. */
  2914. reset(): Matrix;
  2915. /**
  2916. * Adds the current matrix with a second one
  2917. * @param other defines the matrix to add
  2918. * @returns a new matrix as the addition of the current matrix and the given one
  2919. */
  2920. add(other: DeepImmutable<Matrix>): Matrix;
  2921. /**
  2922. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2923. * @param other defines the matrix to add
  2924. * @param result defines the target matrix
  2925. * @returns the current matrix
  2926. */
  2927. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2928. /**
  2929. * Adds in place the given matrix to the current matrix
  2930. * @param other defines the second operand
  2931. * @returns the current updated matrix
  2932. */
  2933. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2934. /**
  2935. * Sets the given matrix to the current inverted Matrix
  2936. * @param other defines the target matrix
  2937. * @returns the unmodified current matrix
  2938. */
  2939. invertToRef(other: Matrix): Matrix;
  2940. /**
  2941. * add a value at the specified position in the current Matrix
  2942. * @param index the index of the value within the matrix. between 0 and 15.
  2943. * @param value the value to be added
  2944. * @returns the current updated matrix
  2945. */
  2946. addAtIndex(index: number, value: number): Matrix;
  2947. /**
  2948. * mutiply the specified position in the current Matrix by a value
  2949. * @param index the index of the value within the matrix. between 0 and 15.
  2950. * @param value the value to be added
  2951. * @returns the current updated matrix
  2952. */
  2953. multiplyAtIndex(index: number, value: number): Matrix;
  2954. /**
  2955. * Inserts the translation vector (using 3 floats) in the current matrix
  2956. * @param x defines the 1st component of the translation
  2957. * @param y defines the 2nd component of the translation
  2958. * @param z defines the 3rd component of the translation
  2959. * @returns the current updated matrix
  2960. */
  2961. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2962. /**
  2963. * Adds the translation vector (using 3 floats) in the current matrix
  2964. * @param x defines the 1st component of the translation
  2965. * @param y defines the 2nd component of the translation
  2966. * @param z defines the 3rd component of the translation
  2967. * @returns the current updated matrix
  2968. */
  2969. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2970. /**
  2971. * Inserts the translation vector in the current matrix
  2972. * @param vector3 defines the translation to insert
  2973. * @returns the current updated matrix
  2974. */
  2975. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2976. /**
  2977. * Gets the translation value of the current matrix
  2978. * @returns a new Vector3 as the extracted translation from the matrix
  2979. */
  2980. getTranslation(): Vector3;
  2981. /**
  2982. * Fill a Vector3 with the extracted translation from the matrix
  2983. * @param result defines the Vector3 where to store the translation
  2984. * @returns the current matrix
  2985. */
  2986. getTranslationToRef(result: Vector3): Matrix;
  2987. /**
  2988. * Remove rotation and scaling part from the matrix
  2989. * @returns the updated matrix
  2990. */
  2991. removeRotationAndScaling(): Matrix;
  2992. /**
  2993. * Multiply two matrices
  2994. * @param other defines the second operand
  2995. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2996. */
  2997. multiply(other: DeepImmutable<Matrix>): Matrix;
  2998. /**
  2999. * Copy the current matrix from the given one
  3000. * @param other defines the source matrix
  3001. * @returns the current updated matrix
  3002. */
  3003. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3004. /**
  3005. * Populates the given array from the starting index with the current matrix values
  3006. * @param array defines the target array
  3007. * @param offset defines the offset in the target array where to start storing values
  3008. * @returns the current matrix
  3009. */
  3010. copyToArray(array: Float32Array, offset?: number): Matrix;
  3011. /**
  3012. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3013. * @param other defines the second operand
  3014. * @param result defines the matrix where to store the multiplication
  3015. * @returns the current matrix
  3016. */
  3017. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3018. /**
  3019. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3020. * @param other defines the second operand
  3021. * @param result defines the array where to store the multiplication
  3022. * @param offset defines the offset in the target array where to start storing values
  3023. * @returns the current matrix
  3024. */
  3025. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3026. /**
  3027. * Check equality between this matrix and a second one
  3028. * @param value defines the second matrix to compare
  3029. * @returns true is the current matrix and the given one values are strictly equal
  3030. */
  3031. equals(value: DeepImmutable<Matrix>): boolean;
  3032. /**
  3033. * Clone the current matrix
  3034. * @returns a new matrix from the current matrix
  3035. */
  3036. clone(): Matrix;
  3037. /**
  3038. * Returns the name of the current matrix class
  3039. * @returns the string "Matrix"
  3040. */
  3041. getClassName(): string;
  3042. /**
  3043. * Gets the hash code of the current matrix
  3044. * @returns the hash code
  3045. */
  3046. getHashCode(): number;
  3047. /**
  3048. * Decomposes the current Matrix into a translation, rotation and scaling components
  3049. * @param scale defines the scale vector3 given as a reference to update
  3050. * @param rotation defines the rotation quaternion given as a reference to update
  3051. * @param translation defines the translation vector3 given as a reference to update
  3052. * @returns true if operation was successful
  3053. */
  3054. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3055. /**
  3056. * Gets specific row of the matrix
  3057. * @param index defines the number of the row to get
  3058. * @returns the index-th row of the current matrix as a new Vector4
  3059. */
  3060. getRow(index: number): Nullable<Vector4>;
  3061. /**
  3062. * Sets the index-th row of the current matrix to the vector4 values
  3063. * @param index defines the number of the row to set
  3064. * @param row defines the target vector4
  3065. * @returns the updated current matrix
  3066. */
  3067. setRow(index: number, row: Vector4): Matrix;
  3068. /**
  3069. * Compute the transpose of the matrix
  3070. * @returns the new transposed matrix
  3071. */
  3072. transpose(): Matrix;
  3073. /**
  3074. * Compute the transpose of the matrix and store it in a given matrix
  3075. * @param result defines the target matrix
  3076. * @returns the current matrix
  3077. */
  3078. transposeToRef(result: Matrix): Matrix;
  3079. /**
  3080. * Sets the index-th row of the current matrix with the given 4 x float values
  3081. * @param index defines the row index
  3082. * @param x defines the x component to set
  3083. * @param y defines the y component to set
  3084. * @param z defines the z component to set
  3085. * @param w defines the w component to set
  3086. * @returns the updated current matrix
  3087. */
  3088. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3089. /**
  3090. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3091. * @param scale defines the scale factor
  3092. * @returns a new matrix
  3093. */
  3094. scale(scale: number): Matrix;
  3095. /**
  3096. * Scale the current matrix values by a factor to a given result matrix
  3097. * @param scale defines the scale factor
  3098. * @param result defines the matrix to store the result
  3099. * @returns the current matrix
  3100. */
  3101. scaleToRef(scale: number, result: Matrix): Matrix;
  3102. /**
  3103. * Scale the current matrix values by a factor and add the result to a given matrix
  3104. * @param scale defines the scale factor
  3105. * @param result defines the Matrix to store the result
  3106. * @returns the current matrix
  3107. */
  3108. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3109. /**
  3110. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3111. * @param ref matrix to store the result
  3112. */
  3113. toNormalMatrix(ref: Matrix): void;
  3114. /**
  3115. * Gets only rotation part of the current matrix
  3116. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3117. */
  3118. getRotationMatrix(): Matrix;
  3119. /**
  3120. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3121. * @param result defines the target matrix to store data to
  3122. * @returns the current matrix
  3123. */
  3124. getRotationMatrixToRef(result: Matrix): Matrix;
  3125. /**
  3126. * Toggles model matrix from being right handed to left handed in place and vice versa
  3127. */
  3128. toggleModelMatrixHandInPlace(): void;
  3129. /**
  3130. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleProjectionMatrixHandInPlace(): void;
  3133. /**
  3134. * Creates a matrix from an array
  3135. * @param array defines the source array
  3136. * @param offset defines an offset in the source array
  3137. * @returns a new Matrix set from the starting index of the given array
  3138. */
  3139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3140. /**
  3141. * Copy the content of an array into a given matrix
  3142. * @param array defines the source array
  3143. * @param offset defines an offset in the source array
  3144. * @param result defines the target matrix
  3145. */
  3146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3147. /**
  3148. * Stores an array into a matrix after having multiplied each component by a given factor
  3149. * @param array defines the source array
  3150. * @param offset defines the offset in the source array
  3151. * @param scale defines the scaling factor
  3152. * @param result defines the target matrix
  3153. */
  3154. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3155. /**
  3156. * Gets an identity matrix that must not be updated
  3157. */
  3158. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3159. /**
  3160. * Stores a list of values (16) inside a given matrix
  3161. * @param initialM11 defines 1st value of 1st row
  3162. * @param initialM12 defines 2nd value of 1st row
  3163. * @param initialM13 defines 3rd value of 1st row
  3164. * @param initialM14 defines 4th value of 1st row
  3165. * @param initialM21 defines 1st value of 2nd row
  3166. * @param initialM22 defines 2nd value of 2nd row
  3167. * @param initialM23 defines 3rd value of 2nd row
  3168. * @param initialM24 defines 4th value of 2nd row
  3169. * @param initialM31 defines 1st value of 3rd row
  3170. * @param initialM32 defines 2nd value of 3rd row
  3171. * @param initialM33 defines 3rd value of 3rd row
  3172. * @param initialM34 defines 4th value of 3rd row
  3173. * @param initialM41 defines 1st value of 4th row
  3174. * @param initialM42 defines 2nd value of 4th row
  3175. * @param initialM43 defines 3rd value of 4th row
  3176. * @param initialM44 defines 4th value of 4th row
  3177. * @param result defines the target matrix
  3178. */
  3179. 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;
  3180. /**
  3181. * Creates new matrix from a list of values (16)
  3182. * @param initialM11 defines 1st value of 1st row
  3183. * @param initialM12 defines 2nd value of 1st row
  3184. * @param initialM13 defines 3rd value of 1st row
  3185. * @param initialM14 defines 4th value of 1st row
  3186. * @param initialM21 defines 1st value of 2nd row
  3187. * @param initialM22 defines 2nd value of 2nd row
  3188. * @param initialM23 defines 3rd value of 2nd row
  3189. * @param initialM24 defines 4th value of 2nd row
  3190. * @param initialM31 defines 1st value of 3rd row
  3191. * @param initialM32 defines 2nd value of 3rd row
  3192. * @param initialM33 defines 3rd value of 3rd row
  3193. * @param initialM34 defines 4th value of 3rd row
  3194. * @param initialM41 defines 1st value of 4th row
  3195. * @param initialM42 defines 2nd value of 4th row
  3196. * @param initialM43 defines 3rd value of 4th row
  3197. * @param initialM44 defines 4th value of 4th row
  3198. * @returns the new matrix
  3199. */
  3200. 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;
  3201. /**
  3202. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3203. * @param scale defines the scale vector3
  3204. * @param rotation defines the rotation quaternion
  3205. * @param translation defines the translation vector3
  3206. * @returns a new matrix
  3207. */
  3208. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3209. /**
  3210. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3211. * @param scale defines the scale vector3
  3212. * @param rotation defines the rotation quaternion
  3213. * @param translation defines the translation vector3
  3214. * @param result defines the target matrix
  3215. */
  3216. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3217. /**
  3218. * Creates a new identity matrix
  3219. * @returns a new identity matrix
  3220. */
  3221. static Identity(): Matrix;
  3222. /**
  3223. * Creates a new identity matrix and stores the result in a given matrix
  3224. * @param result defines the target matrix
  3225. */
  3226. static IdentityToRef(result: Matrix): void;
  3227. /**
  3228. * Creates a new zero matrix
  3229. * @returns a new zero matrix
  3230. */
  3231. static Zero(): Matrix;
  3232. /**
  3233. * Creates a new rotation matrix for "angle" radians around the X axis
  3234. * @param angle defines the angle (in radians) to use
  3235. * @return the new matrix
  3236. */
  3237. static RotationX(angle: number): Matrix;
  3238. /**
  3239. * Creates a new matrix as the invert of a given matrix
  3240. * @param source defines the source matrix
  3241. * @returns the new matrix
  3242. */
  3243. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3244. /**
  3245. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3246. * @param angle defines the angle (in radians) to use
  3247. * @param result defines the target matrix
  3248. */
  3249. static RotationXToRef(angle: number, result: Matrix): void;
  3250. /**
  3251. * Creates a new rotation matrix for "angle" radians around the Y axis
  3252. * @param angle defines the angle (in radians) to use
  3253. * @return the new matrix
  3254. */
  3255. static RotationY(angle: number): Matrix;
  3256. /**
  3257. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3258. * @param angle defines the angle (in radians) to use
  3259. * @param result defines the target matrix
  3260. */
  3261. static RotationYToRef(angle: number, result: Matrix): void;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the Z axis
  3264. * @param angle defines the angle (in radians) to use
  3265. * @return the new matrix
  3266. */
  3267. static RotationZ(angle: number): Matrix;
  3268. /**
  3269. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3270. * @param angle defines the angle (in radians) to use
  3271. * @param result defines the target matrix
  3272. */
  3273. static RotationZToRef(angle: number, result: Matrix): void;
  3274. /**
  3275. * Creates a new rotation matrix for "angle" radians around the given axis
  3276. * @param axis defines the axis to use
  3277. * @param angle defines the angle (in radians) to use
  3278. * @return the new matrix
  3279. */
  3280. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3281. /**
  3282. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3283. * @param axis defines the axis to use
  3284. * @param angle defines the angle (in radians) to use
  3285. * @param result defines the target matrix
  3286. */
  3287. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3288. /**
  3289. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3290. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3291. * @param from defines the vector to align
  3292. * @param to defines the vector to align to
  3293. * @param result defines the target matrix
  3294. */
  3295. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3296. /**
  3297. * Creates a rotation matrix
  3298. * @param yaw defines the yaw angle in radians (Y axis)
  3299. * @param pitch defines the pitch angle in radians (X axis)
  3300. * @param roll defines the roll angle in radians (X axis)
  3301. * @returns the new rotation matrix
  3302. */
  3303. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3304. /**
  3305. * Creates a rotation matrix and stores it in a given matrix
  3306. * @param yaw defines the yaw angle in radians (Y axis)
  3307. * @param pitch defines the pitch angle in radians (X axis)
  3308. * @param roll defines the roll angle in radians (X axis)
  3309. * @param result defines the target matrix
  3310. */
  3311. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3312. /**
  3313. * Creates a scaling matrix
  3314. * @param x defines the scale factor on X axis
  3315. * @param y defines the scale factor on Y axis
  3316. * @param z defines the scale factor on Z axis
  3317. * @returns the new matrix
  3318. */
  3319. static Scaling(x: number, y: number, z: number): Matrix;
  3320. /**
  3321. * Creates a scaling matrix and stores it in a given matrix
  3322. * @param x defines the scale factor on X axis
  3323. * @param y defines the scale factor on Y axis
  3324. * @param z defines the scale factor on Z axis
  3325. * @param result defines the target matrix
  3326. */
  3327. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3328. /**
  3329. * Creates a translation matrix
  3330. * @param x defines the translation on X axis
  3331. * @param y defines the translation on Y axis
  3332. * @param z defines the translationon Z axis
  3333. * @returns the new matrix
  3334. */
  3335. static Translation(x: number, y: number, z: number): Matrix;
  3336. /**
  3337. * Creates a translation matrix and stores it in a given matrix
  3338. * @param x defines the translation on X axis
  3339. * @param y defines the translation on Y axis
  3340. * @param z defines the translationon Z axis
  3341. * @param result defines the target matrix
  3342. */
  3343. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3344. /**
  3345. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3346. * @param startValue defines the start value
  3347. * @param endValue defines the end value
  3348. * @param gradient defines the gradient factor
  3349. * @returns the new matrix
  3350. */
  3351. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3354. * @param startValue defines the start value
  3355. * @param endValue defines the end value
  3356. * @param gradient defines the gradient factor
  3357. * @param result defines the Matrix object where to store data
  3358. */
  3359. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3360. /**
  3361. * Builds a new matrix whose values are computed by:
  3362. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3363. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3364. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3365. * @param startValue defines the first matrix
  3366. * @param endValue defines the second matrix
  3367. * @param gradient defines the gradient between the two matrices
  3368. * @returns the new matrix
  3369. */
  3370. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3371. /**
  3372. * Update a matrix to values which are computed by:
  3373. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3374. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3375. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3376. * @param startValue defines the first matrix
  3377. * @param endValue defines the second matrix
  3378. * @param gradient defines the gradient between the two matrices
  3379. * @param result defines the target matrix
  3380. */
  3381. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3382. /**
  3383. * 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"
  3384. * This function works in left handed mode
  3385. * @param eye defines the final position of the entity
  3386. * @param target defines where the entity should look at
  3387. * @param up defines the up vector for the entity
  3388. * @returns the new matrix
  3389. */
  3390. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3391. /**
  3392. * 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".
  3393. * This function works in left handed mode
  3394. * @param eye defines the final position of the entity
  3395. * @param target defines where the entity should look at
  3396. * @param up defines the up vector for the entity
  3397. * @param result defines the target matrix
  3398. */
  3399. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3400. /**
  3401. * 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"
  3402. * This function works in right handed mode
  3403. * @param eye defines the final position of the entity
  3404. * @param target defines where the entity should look at
  3405. * @param up defines the up vector for the entity
  3406. * @returns the new matrix
  3407. */
  3408. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3409. /**
  3410. * 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".
  3411. * This function works in right handed mode
  3412. * @param eye defines the final position of the entity
  3413. * @param target defines where the entity should look at
  3414. * @param up defines the up vector for the entity
  3415. * @param result defines the target matrix
  3416. */
  3417. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3418. /**
  3419. * Create a left-handed orthographic projection matrix
  3420. * @param width defines the viewport width
  3421. * @param height defines the viewport height
  3422. * @param znear defines the near clip plane
  3423. * @param zfar defines the far clip plane
  3424. * @returns a new matrix as a left-handed orthographic projection matrix
  3425. */
  3426. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3427. /**
  3428. * Store a left-handed orthographic projection to a given matrix
  3429. * @param width defines the viewport width
  3430. * @param height defines the viewport height
  3431. * @param znear defines the near clip plane
  3432. * @param zfar defines the far clip plane
  3433. * @param result defines the target matrix
  3434. */
  3435. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3436. /**
  3437. * Create a left-handed orthographic projection matrix
  3438. * @param left defines the viewport left coordinate
  3439. * @param right defines the viewport right coordinate
  3440. * @param bottom defines the viewport bottom coordinate
  3441. * @param top defines the viewport top coordinate
  3442. * @param znear defines the near clip plane
  3443. * @param zfar defines the far clip plane
  3444. * @returns a new matrix as a left-handed orthographic projection matrix
  3445. */
  3446. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3447. /**
  3448. * Stores a left-handed orthographic projection into a given matrix
  3449. * @param left defines the viewport left coordinate
  3450. * @param right defines the viewport right coordinate
  3451. * @param bottom defines the viewport bottom coordinate
  3452. * @param top defines the viewport top coordinate
  3453. * @param znear defines the near clip plane
  3454. * @param zfar defines the far clip plane
  3455. * @param result defines the target matrix
  3456. */
  3457. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3458. /**
  3459. * Creates a right-handed orthographic projection matrix
  3460. * @param left defines the viewport left coordinate
  3461. * @param right defines the viewport right coordinate
  3462. * @param bottom defines the viewport bottom coordinate
  3463. * @param top defines the viewport top coordinate
  3464. * @param znear defines the near clip plane
  3465. * @param zfar defines the far clip plane
  3466. * @returns a new matrix as a right-handed orthographic projection matrix
  3467. */
  3468. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3469. /**
  3470. * Stores a right-handed orthographic projection into a given matrix
  3471. * @param left defines the viewport left coordinate
  3472. * @param right defines the viewport right coordinate
  3473. * @param bottom defines the viewport bottom coordinate
  3474. * @param top defines the viewport top coordinate
  3475. * @param znear defines the near clip plane
  3476. * @param zfar defines the far clip plane
  3477. * @param result defines the target matrix
  3478. */
  3479. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3480. /**
  3481. * Creates a left-handed perspective projection matrix
  3482. * @param width defines the viewport width
  3483. * @param height defines the viewport height
  3484. * @param znear defines the near clip plane
  3485. * @param zfar defines the far clip plane
  3486. * @returns a new matrix as a left-handed perspective projection matrix
  3487. */
  3488. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3489. /**
  3490. * Creates a left-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a left-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a left-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Creates a right-handed perspective projection matrix
  3510. * @param fov defines the horizontal field of view
  3511. * @param aspect defines the aspect ratio
  3512. * @param znear defines the near clip plane
  3513. * @param zfar defines the far clip plane
  3514. * @returns a new matrix as a right-handed perspective projection matrix
  3515. */
  3516. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3517. /**
  3518. * Stores a right-handed perspective projection into a given matrix
  3519. * @param fov defines the horizontal field of view
  3520. * @param aspect defines the aspect ratio
  3521. * @param znear defines the near clip plane
  3522. * @param zfar defines the far clip plane
  3523. * @param result defines the target matrix
  3524. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3525. */
  3526. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3527. /**
  3528. * Stores a perspective projection for WebVR info a given matrix
  3529. * @param fov defines the field of view
  3530. * @param znear defines the near clip plane
  3531. * @param zfar defines the far clip plane
  3532. * @param result defines the target matrix
  3533. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3534. */
  3535. static PerspectiveFovWebVRToRef(fov: {
  3536. upDegrees: number;
  3537. downDegrees: number;
  3538. leftDegrees: number;
  3539. rightDegrees: number;
  3540. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3541. /**
  3542. * Computes a complete transformation matrix
  3543. * @param viewport defines the viewport to use
  3544. * @param world defines the world matrix
  3545. * @param view defines the view matrix
  3546. * @param projection defines the projection matrix
  3547. * @param zmin defines the near clip plane
  3548. * @param zmax defines the far clip plane
  3549. * @returns the transformation matrix
  3550. */
  3551. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3552. /**
  3553. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3554. * @param matrix defines the matrix to use
  3555. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3556. */
  3557. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3558. /**
  3559. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3560. * @param matrix defines the matrix to use
  3561. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3562. */
  3563. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3564. /**
  3565. * Compute the transpose of a given matrix
  3566. * @param matrix defines the matrix to transpose
  3567. * @returns the new matrix
  3568. */
  3569. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3570. /**
  3571. * Compute the transpose of a matrix and store it in a target matrix
  3572. * @param matrix defines the matrix to transpose
  3573. * @param result defines the target matrix
  3574. */
  3575. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3576. /**
  3577. * Computes a reflection matrix from a plane
  3578. * @param plane defines the reflection plane
  3579. * @returns a new matrix
  3580. */
  3581. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3582. /**
  3583. * Computes a reflection matrix from a plane
  3584. * @param plane defines the reflection plane
  3585. * @param result defines the target matrix
  3586. */
  3587. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3588. /**
  3589. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3590. * @param xaxis defines the value of the 1st axis
  3591. * @param yaxis defines the value of the 2nd axis
  3592. * @param zaxis defines the value of the 3rd axis
  3593. * @param result defines the target matrix
  3594. */
  3595. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3596. /**
  3597. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3598. * @param quat defines the quaternion to use
  3599. * @param result defines the target matrix
  3600. */
  3601. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3602. }
  3603. /**
  3604. * Represens a plane by the equation ax + by + cz + d = 0
  3605. */
  3606. export class Plane {
  3607. /**
  3608. * Normal of the plane (a,b,c)
  3609. */
  3610. normal: Vector3;
  3611. /**
  3612. * d component of the plane
  3613. */
  3614. d: number;
  3615. /**
  3616. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3617. * @param a a component of the plane
  3618. * @param b b component of the plane
  3619. * @param c c component of the plane
  3620. * @param d d component of the plane
  3621. */
  3622. constructor(a: number, b: number, c: number, d: number);
  3623. /**
  3624. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3625. */
  3626. asArray(): number[];
  3627. /**
  3628. * @returns a new plane copied from the current Plane.
  3629. */
  3630. clone(): Plane;
  3631. /**
  3632. * @returns the string "Plane".
  3633. */
  3634. getClassName(): string;
  3635. /**
  3636. * @returns the Plane hash code.
  3637. */
  3638. getHashCode(): number;
  3639. /**
  3640. * Normalize the current Plane in place.
  3641. * @returns the updated Plane.
  3642. */
  3643. normalize(): Plane;
  3644. /**
  3645. * Applies a transformation the plane and returns the result
  3646. * @param transformation the transformation matrix to be applied to the plane
  3647. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3648. */
  3649. transform(transformation: DeepImmutable<Matrix>): Plane;
  3650. /**
  3651. * Calcualtte the dot product between the point and the plane normal
  3652. * @param point point to calculate the dot product with
  3653. * @returns the dot product (float) of the point coordinates and the plane normal.
  3654. */
  3655. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3656. /**
  3657. * Updates the current Plane from the plane defined by the three given points.
  3658. * @param point1 one of the points used to contruct the plane
  3659. * @param point2 one of the points used to contruct the plane
  3660. * @param point3 one of the points used to contruct the plane
  3661. * @returns the updated Plane.
  3662. */
  3663. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3664. /**
  3665. * Checks if the plane is facing a given direction
  3666. * @param direction the direction to check if the plane is facing
  3667. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3668. * @returns True is the vector "direction" is the same side than the plane normal.
  3669. */
  3670. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3671. /**
  3672. * Calculates the distance to a point
  3673. * @param point point to calculate distance to
  3674. * @returns the signed distance (float) from the given point to the Plane.
  3675. */
  3676. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3677. /**
  3678. * Creates a plane from an array
  3679. * @param array the array to create a plane from
  3680. * @returns a new Plane from the given array.
  3681. */
  3682. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3683. /**
  3684. * Creates a plane from three points
  3685. * @param point1 point used to create the plane
  3686. * @param point2 point used to create the plane
  3687. * @param point3 point used to create the plane
  3688. * @returns a new Plane defined by the three given points.
  3689. */
  3690. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3691. /**
  3692. * Creates a plane from an origin point and a normal
  3693. * @param origin origin of the plane to be constructed
  3694. * @param normal normal of the plane to be constructed
  3695. * @returns a new Plane the normal vector to this plane at the given origin point.
  3696. * Note : the vector "normal" is updated because normalized.
  3697. */
  3698. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3699. /**
  3700. * Calculates the distance from a plane and a point
  3701. * @param origin origin of the plane to be constructed
  3702. * @param normal normal of the plane to be constructed
  3703. * @param point point to calculate distance to
  3704. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3705. */
  3706. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3707. }
  3708. /**
  3709. * Class used to represent a viewport on screen
  3710. */
  3711. export class Viewport {
  3712. /** viewport left coordinate */
  3713. x: number;
  3714. /** viewport top coordinate */
  3715. y: number;
  3716. /**viewport width */
  3717. width: number;
  3718. /** viewport height */
  3719. height: number;
  3720. /**
  3721. * Creates a Viewport object located at (x, y) and sized (width, height)
  3722. * @param x defines viewport left coordinate
  3723. * @param y defines viewport top coordinate
  3724. * @param width defines the viewport width
  3725. * @param height defines the viewport height
  3726. */
  3727. constructor(
  3728. /** viewport left coordinate */
  3729. x: number,
  3730. /** viewport top coordinate */
  3731. y: number,
  3732. /**viewport width */
  3733. width: number,
  3734. /** viewport height */
  3735. height: number);
  3736. /**
  3737. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3738. * @param renderWidth defines the rendering width
  3739. * @param renderHeight defines the rendering height
  3740. * @returns a new Viewport
  3741. */
  3742. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3743. /**
  3744. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3745. * @param renderWidth defines the rendering width
  3746. * @param renderHeight defines the rendering height
  3747. * @param ref defines the target viewport
  3748. * @returns the current viewport
  3749. */
  3750. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3751. /**
  3752. * Returns a new Viewport copied from the current one
  3753. * @returns a new Viewport
  3754. */
  3755. clone(): Viewport;
  3756. }
  3757. /**
  3758. * Reprasents a camera frustum
  3759. */
  3760. export class Frustum {
  3761. /**
  3762. * Gets the planes representing the frustum
  3763. * @param transform matrix to be applied to the returned planes
  3764. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3765. */
  3766. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3767. /**
  3768. * Gets the near frustum plane transformed by the transform matrix
  3769. * @param transform transformation matrix to be applied to the resulting frustum plane
  3770. * @param frustumPlane the resuling frustum plane
  3771. */
  3772. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3773. /**
  3774. * Gets the far frustum plane transformed by the transform matrix
  3775. * @param transform transformation matrix to be applied to the resulting frustum plane
  3776. * @param frustumPlane the resuling frustum plane
  3777. */
  3778. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3779. /**
  3780. * Gets the left frustum plane transformed by the transform matrix
  3781. * @param transform transformation matrix to be applied to the resulting frustum plane
  3782. * @param frustumPlane the resuling frustum plane
  3783. */
  3784. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3785. /**
  3786. * Gets the right frustum plane transformed by the transform matrix
  3787. * @param transform transformation matrix to be applied to the resulting frustum plane
  3788. * @param frustumPlane the resuling frustum plane
  3789. */
  3790. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3791. /**
  3792. * Gets the top frustum plane transformed by the transform matrix
  3793. * @param transform transformation matrix to be applied to the resulting frustum plane
  3794. * @param frustumPlane the resuling frustum plane
  3795. */
  3796. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3797. /**
  3798. * Gets the bottom frustum plane transformed by the transform matrix
  3799. * @param transform transformation matrix to be applied to the resulting frustum plane
  3800. * @param frustumPlane the resuling frustum plane
  3801. */
  3802. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3803. /**
  3804. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3805. * @param transform transformation matrix to be applied to the resulting frustum planes
  3806. * @param frustumPlanes the resuling frustum planes
  3807. */
  3808. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3809. }
  3810. /** Defines supported spaces */
  3811. export enum Space {
  3812. /** Local (object) space */
  3813. LOCAL = 0,
  3814. /** World space */
  3815. WORLD = 1,
  3816. /** Bone space */
  3817. BONE = 2
  3818. }
  3819. /** Defines the 3 main axes */
  3820. export class Axis {
  3821. /** X axis */
  3822. static X: Vector3;
  3823. /** Y axis */
  3824. static Y: Vector3;
  3825. /** Z axis */
  3826. static Z: Vector3;
  3827. }
  3828. /** Class used to represent a Bezier curve */
  3829. export class BezierCurve {
  3830. /**
  3831. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3832. * @param t defines the time
  3833. * @param x1 defines the left coordinate on X axis
  3834. * @param y1 defines the left coordinate on Y axis
  3835. * @param x2 defines the right coordinate on X axis
  3836. * @param y2 defines the right coordinate on Y axis
  3837. * @returns the interpolated value
  3838. */
  3839. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3840. }
  3841. /**
  3842. * Defines potential orientation for back face culling
  3843. */
  3844. export enum Orientation {
  3845. /**
  3846. * Clockwise
  3847. */
  3848. CW = 0,
  3849. /** Counter clockwise */
  3850. CCW = 1
  3851. }
  3852. /**
  3853. * Defines angle representation
  3854. */
  3855. export class Angle {
  3856. private _radians;
  3857. /**
  3858. * Creates an Angle object of "radians" radians (float).
  3859. * @param radians the angle in radians
  3860. */
  3861. constructor(radians: number);
  3862. /**
  3863. * Get value in degrees
  3864. * @returns the Angle value in degrees (float)
  3865. */
  3866. degrees(): number;
  3867. /**
  3868. * Get value in radians
  3869. * @returns the Angle value in radians (float)
  3870. */
  3871. radians(): number;
  3872. /**
  3873. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3874. * @param a defines first vector
  3875. * @param b defines second vector
  3876. * @returns a new Angle
  3877. */
  3878. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3879. /**
  3880. * Gets a new Angle object from the given float in radians
  3881. * @param radians defines the angle value in radians
  3882. * @returns a new Angle
  3883. */
  3884. static FromRadians(radians: number): Angle;
  3885. /**
  3886. * Gets a new Angle object from the given float in degrees
  3887. * @param degrees defines the angle value in degrees
  3888. * @returns a new Angle
  3889. */
  3890. static FromDegrees(degrees: number): Angle;
  3891. }
  3892. /**
  3893. * This represents an arc in a 2d space.
  3894. */
  3895. export class Arc2 {
  3896. /** Defines the start point of the arc */
  3897. startPoint: Vector2;
  3898. /** Defines the mid point of the arc */
  3899. midPoint: Vector2;
  3900. /** Defines the end point of the arc */
  3901. endPoint: Vector2;
  3902. /**
  3903. * Defines the center point of the arc.
  3904. */
  3905. centerPoint: Vector2;
  3906. /**
  3907. * Defines the radius of the arc.
  3908. */
  3909. radius: number;
  3910. /**
  3911. * Defines the angle of the arc (from mid point to end point).
  3912. */
  3913. angle: Angle;
  3914. /**
  3915. * Defines the start angle of the arc (from start point to middle point).
  3916. */
  3917. startAngle: Angle;
  3918. /**
  3919. * Defines the orientation of the arc (clock wise/counter clock wise).
  3920. */
  3921. orientation: Orientation;
  3922. /**
  3923. * Creates an Arc object from the three given points : start, middle and end.
  3924. * @param startPoint Defines the start point of the arc
  3925. * @param midPoint Defines the midlle point of the arc
  3926. * @param endPoint Defines the end point of the arc
  3927. */
  3928. constructor(
  3929. /** Defines the start point of the arc */
  3930. startPoint: Vector2,
  3931. /** Defines the mid point of the arc */
  3932. midPoint: Vector2,
  3933. /** Defines the end point of the arc */
  3934. endPoint: Vector2);
  3935. }
  3936. /**
  3937. * Represents a 2D path made up of multiple 2D points
  3938. */
  3939. export class Path2 {
  3940. private _points;
  3941. private _length;
  3942. /**
  3943. * If the path start and end point are the same
  3944. */
  3945. closed: boolean;
  3946. /**
  3947. * Creates a Path2 object from the starting 2D coordinates x and y.
  3948. * @param x the starting points x value
  3949. * @param y the starting points y value
  3950. */
  3951. constructor(x: number, y: number);
  3952. /**
  3953. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3954. * @param x the added points x value
  3955. * @param y the added points y value
  3956. * @returns the updated Path2.
  3957. */
  3958. addLineTo(x: number, y: number): Path2;
  3959. /**
  3960. * 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.
  3961. * @param midX middle point x value
  3962. * @param midY middle point y value
  3963. * @param endX end point x value
  3964. * @param endY end point y value
  3965. * @param numberOfSegments (default: 36)
  3966. * @returns the updated Path2.
  3967. */
  3968. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3969. /**
  3970. * Closes the Path2.
  3971. * @returns the Path2.
  3972. */
  3973. close(): Path2;
  3974. /**
  3975. * Gets the sum of the distance between each sequential point in the path
  3976. * @returns the Path2 total length (float).
  3977. */
  3978. length(): number;
  3979. /**
  3980. * Gets the points which construct the path
  3981. * @returns the Path2 internal array of points.
  3982. */
  3983. getPoints(): Vector2[];
  3984. /**
  3985. * Retreives the point at the distance aways from the starting point
  3986. * @param normalizedLengthPosition the length along the path to retreive the point from
  3987. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3988. */
  3989. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3990. /**
  3991. * Creates a new path starting from an x and y position
  3992. * @param x starting x value
  3993. * @param y starting y value
  3994. * @returns a new Path2 starting at the coordinates (x, y).
  3995. */
  3996. static StartingAt(x: number, y: number): Path2;
  3997. }
  3998. /**
  3999. * Represents a 3D path made up of multiple 3D points
  4000. */
  4001. export class Path3D {
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[];
  4006. private _curve;
  4007. private _distances;
  4008. private _tangents;
  4009. private _normals;
  4010. private _binormals;
  4011. private _raw;
  4012. /**
  4013. * new Path3D(path, normal, raw)
  4014. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4015. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4016. * @param path an array of Vector3, the curve axis of the Path3D
  4017. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4018. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4019. */
  4020. constructor(
  4021. /**
  4022. * an array of Vector3, the curve axis of the Path3D
  4023. */
  4024. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4025. /**
  4026. * Returns the Path3D array of successive Vector3 designing its curve.
  4027. * @returns the Path3D array of successive Vector3 designing its curve.
  4028. */
  4029. getCurve(): Vector3[];
  4030. /**
  4031. * Returns an array populated with tangent vectors on each Path3D curve point.
  4032. * @returns an array populated with tangent vectors on each Path3D curve point.
  4033. */
  4034. getTangents(): Vector3[];
  4035. /**
  4036. * Returns an array populated with normal vectors on each Path3D curve point.
  4037. * @returns an array populated with normal vectors on each Path3D curve point.
  4038. */
  4039. getNormals(): Vector3[];
  4040. /**
  4041. * Returns an array populated with binormal vectors on each Path3D curve point.
  4042. * @returns an array populated with binormal vectors on each Path3D curve point.
  4043. */
  4044. getBinormals(): Vector3[];
  4045. /**
  4046. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4047. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4048. */
  4049. getDistances(): number[];
  4050. /**
  4051. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4052. * @param path path which all values are copied into the curves points
  4053. * @param firstNormal which should be projected onto the curve
  4054. * @returns the same object updated.
  4055. */
  4056. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4057. private _compute;
  4058. private _getFirstNonNullVector;
  4059. private _getLastNonNullVector;
  4060. private _normalVector;
  4061. }
  4062. /**
  4063. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4064. * A Curve3 is designed from a series of successive Vector3.
  4065. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4066. */
  4067. export class Curve3 {
  4068. private _points;
  4069. private _length;
  4070. /**
  4071. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4072. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4073. * @param v1 (Vector3) the control point
  4074. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4075. * @param nbPoints (integer) the wanted number of points in the curve
  4076. * @returns the created Curve3
  4077. */
  4078. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4079. /**
  4080. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4081. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4082. * @param v1 (Vector3) the first control point
  4083. * @param v2 (Vector3) the second control point
  4084. * @param v3 (Vector3) the end point of the Cubic Bezier
  4085. * @param nbPoints (integer) the wanted number of points in the curve
  4086. * @returns the created Curve3
  4087. */
  4088. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4089. /**
  4090. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4091. * @param p1 (Vector3) the origin point of the Hermite Spline
  4092. * @param t1 (Vector3) the tangent vector at the origin point
  4093. * @param p2 (Vector3) the end point of the Hermite Spline
  4094. * @param t2 (Vector3) the tangent vector at the end point
  4095. * @param nbPoints (integer) the wanted number of points in the curve
  4096. * @returns the created Curve3
  4097. */
  4098. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4099. /**
  4100. * Returns a Curve3 object along a CatmullRom Spline curve :
  4101. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4102. * @param nbPoints (integer) the wanted number of points between each curve control points
  4103. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4104. * @returns the created Curve3
  4105. */
  4106. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4107. /**
  4108. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4109. * A Curve3 is designed from a series of successive Vector3.
  4110. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4111. * @param points points which make up the curve
  4112. */
  4113. constructor(points: Vector3[]);
  4114. /**
  4115. * @returns the Curve3 stored array of successive Vector3
  4116. */
  4117. getPoints(): Vector3[];
  4118. /**
  4119. * @returns the computed length (float) of the curve.
  4120. */
  4121. length(): number;
  4122. /**
  4123. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4124. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4125. * curveA and curveB keep unchanged.
  4126. * @param curve the curve to continue from this curve
  4127. * @returns the newly constructed curve
  4128. */
  4129. continue(curve: DeepImmutable<Curve3>): Curve3;
  4130. private _computeLength;
  4131. }
  4132. /**
  4133. * Contains position and normal vectors for a vertex
  4134. */
  4135. export class PositionNormalVertex {
  4136. /** the position of the vertex (defaut: 0,0,0) */
  4137. position: Vector3;
  4138. /** the normal of the vertex (defaut: 0,1,0) */
  4139. normal: Vector3;
  4140. /**
  4141. * Creates a PositionNormalVertex
  4142. * @param position the position of the vertex (defaut: 0,0,0)
  4143. * @param normal the normal of the vertex (defaut: 0,1,0)
  4144. */
  4145. constructor(
  4146. /** the position of the vertex (defaut: 0,0,0) */
  4147. position?: Vector3,
  4148. /** the normal of the vertex (defaut: 0,1,0) */
  4149. normal?: Vector3);
  4150. /**
  4151. * Clones the PositionNormalVertex
  4152. * @returns the cloned PositionNormalVertex
  4153. */
  4154. clone(): PositionNormalVertex;
  4155. }
  4156. /**
  4157. * Contains position, normal and uv vectors for a vertex
  4158. */
  4159. export class PositionNormalTextureVertex {
  4160. /** the position of the vertex (defaut: 0,0,0) */
  4161. position: Vector3;
  4162. /** the normal of the vertex (defaut: 0,1,0) */
  4163. normal: Vector3;
  4164. /** the uv of the vertex (default: 0,0) */
  4165. uv: Vector2;
  4166. /**
  4167. * Creates a PositionNormalTextureVertex
  4168. * @param position the position of the vertex (defaut: 0,0,0)
  4169. * @param normal the normal of the vertex (defaut: 0,1,0)
  4170. * @param uv the uv of the vertex (default: 0,0)
  4171. */
  4172. constructor(
  4173. /** the position of the vertex (defaut: 0,0,0) */
  4174. position?: Vector3,
  4175. /** the normal of the vertex (defaut: 0,1,0) */
  4176. normal?: Vector3,
  4177. /** the uv of the vertex (default: 0,0) */
  4178. uv?: Vector2);
  4179. /**
  4180. * Clones the PositionNormalTextureVertex
  4181. * @returns the cloned PositionNormalTextureVertex
  4182. */
  4183. clone(): PositionNormalTextureVertex;
  4184. }
  4185. /**
  4186. * @hidden
  4187. */
  4188. export class Tmp {
  4189. static Color3: Color3[];
  4190. static Color4: Color4[];
  4191. static Vector2: Vector2[];
  4192. static Vector3: Vector3[];
  4193. static Vector4: Vector4[];
  4194. static Quaternion: Quaternion[];
  4195. static Matrix: Matrix[];
  4196. }
  4197. }
  4198. declare module BABYLON {
  4199. /**
  4200. * Class used to enable access to offline support
  4201. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4202. */
  4203. export interface IOfflineProvider {
  4204. /**
  4205. * Gets a boolean indicating if scene must be saved in the database
  4206. */
  4207. enableSceneOffline: boolean;
  4208. /**
  4209. * Gets a boolean indicating if textures must be saved in the database
  4210. */
  4211. enableTexturesOffline: boolean;
  4212. /**
  4213. * Open the offline support and make it available
  4214. * @param successCallback defines the callback to call on success
  4215. * @param errorCallback defines the callback to call on error
  4216. */
  4217. open(successCallback: () => void, errorCallback: () => void): void;
  4218. /**
  4219. * Loads an image from the offline support
  4220. * @param url defines the url to load from
  4221. * @param image defines the target DOM image
  4222. */
  4223. loadImage(url: string, image: HTMLImageElement): void;
  4224. /**
  4225. * Loads a file from offline support
  4226. * @param url defines the URL to load from
  4227. * @param sceneLoaded defines a callback to call on success
  4228. * @param progressCallBack defines a callback to call when progress changed
  4229. * @param errorCallback defines a callback to call on error
  4230. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4231. */
  4232. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4233. }
  4234. }
  4235. declare module BABYLON {
  4236. /**
  4237. * A class serves as a medium between the observable and its observers
  4238. */
  4239. export class EventState {
  4240. /**
  4241. * Create a new EventState
  4242. * @param mask defines the mask associated with this state
  4243. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4244. * @param target defines the original target of the state
  4245. * @param currentTarget defines the current target of the state
  4246. */
  4247. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4248. /**
  4249. * Initialize the current event state
  4250. * @param mask defines the mask associated with this state
  4251. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4252. * @param target defines the original target of the state
  4253. * @param currentTarget defines the current target of the state
  4254. * @returns the current event state
  4255. */
  4256. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4257. /**
  4258. * An Observer can set this property to true to prevent subsequent observers of being notified
  4259. */
  4260. skipNextObservers: boolean;
  4261. /**
  4262. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4263. */
  4264. mask: number;
  4265. /**
  4266. * The object that originally notified the event
  4267. */
  4268. target?: any;
  4269. /**
  4270. * The current object in the bubbling phase
  4271. */
  4272. currentTarget?: any;
  4273. /**
  4274. * This will be populated with the return value of the last function that was executed.
  4275. * If it is the first function in the callback chain it will be the event data.
  4276. */
  4277. lastReturnValue?: any;
  4278. }
  4279. /**
  4280. * Represent an Observer registered to a given Observable object.
  4281. */
  4282. export class Observer<T> {
  4283. /**
  4284. * Defines the callback to call when the observer is notified
  4285. */
  4286. callback: (eventData: T, eventState: EventState) => void;
  4287. /**
  4288. * Defines the mask of the observer (used to filter notifications)
  4289. */
  4290. mask: number;
  4291. /**
  4292. * Defines the current scope used to restore the JS context
  4293. */
  4294. scope: any;
  4295. /** @hidden */ private _willBeUnregistered: boolean;
  4296. /**
  4297. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4298. */
  4299. unregisterOnNextCall: boolean;
  4300. /**
  4301. * Creates a new observer
  4302. * @param callback defines the callback to call when the observer is notified
  4303. * @param mask defines the mask of the observer (used to filter notifications)
  4304. * @param scope defines the current scope used to restore the JS context
  4305. */
  4306. constructor(
  4307. /**
  4308. * Defines the callback to call when the observer is notified
  4309. */
  4310. callback: (eventData: T, eventState: EventState) => void,
  4311. /**
  4312. * Defines the mask of the observer (used to filter notifications)
  4313. */
  4314. mask: number,
  4315. /**
  4316. * Defines the current scope used to restore the JS context
  4317. */
  4318. scope?: any);
  4319. }
  4320. /**
  4321. * Represent a list of observers registered to multiple Observables object.
  4322. */
  4323. export class MultiObserver<T> {
  4324. private _observers;
  4325. private _observables;
  4326. /**
  4327. * Release associated resources
  4328. */
  4329. dispose(): void;
  4330. /**
  4331. * Raise a callback when one of the observable will notify
  4332. * @param observables defines a list of observables to watch
  4333. * @param callback defines the callback to call on notification
  4334. * @param mask defines the mask used to filter notifications
  4335. * @param scope defines the current scope used to restore the JS context
  4336. * @returns the new MultiObserver
  4337. */
  4338. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4339. }
  4340. /**
  4341. * The Observable class is a simple implementation of the Observable pattern.
  4342. *
  4343. * 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.
  4344. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4345. * 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).
  4346. * 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.
  4347. */
  4348. export class Observable<T> {
  4349. private _observers;
  4350. private _eventState;
  4351. private _onObserverAdded;
  4352. /**
  4353. * Creates a new observable
  4354. * @param onObserverAdded defines a callback to call when a new observer is added
  4355. */
  4356. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4357. /**
  4358. * Create a new Observer with the specified callback
  4359. * @param callback the callback that will be executed for that Observer
  4360. * @param mask the mask used to filter observers
  4361. * @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.
  4362. * @param scope optional scope for the callback to be called from
  4363. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4364. * @returns the new observer created for the callback
  4365. */
  4366. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4367. /**
  4368. * Create a new Observer with the specified callback and unregisters after the next notification
  4369. * @param callback the callback that will be executed for that Observer
  4370. * @returns the new observer created for the callback
  4371. */
  4372. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4373. /**
  4374. * Remove an Observer from the Observable object
  4375. * @param observer the instance of the Observer to remove
  4376. * @returns false if it doesn't belong to this Observable
  4377. */
  4378. remove(observer: Nullable<Observer<T>>): boolean;
  4379. /**
  4380. * Remove a callback from the Observable object
  4381. * @param callback the callback to remove
  4382. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4383. * @returns false if it doesn't belong to this Observable
  4384. */
  4385. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4386. private _deferUnregister;
  4387. private _remove;
  4388. /**
  4389. * Moves the observable to the top of the observer list making it get called first when notified
  4390. * @param observer the observer to move
  4391. */
  4392. makeObserverTopPriority(observer: Observer<T>): void;
  4393. /**
  4394. * Moves the observable to the bottom of the observer list making it get called last when notified
  4395. * @param observer the observer to move
  4396. */
  4397. makeObserverBottomPriority(observer: Observer<T>): void;
  4398. /**
  4399. * Notify all Observers by calling their respective callback with the given data
  4400. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4401. * @param eventData defines the data to send to all observers
  4402. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4403. * @param target defines the original target of the state
  4404. * @param currentTarget defines the current target of the state
  4405. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4406. */
  4407. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4408. /**
  4409. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4410. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4411. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4412. * and it is crucial that all callbacks will be executed.
  4413. * The order of the callbacks is kept, callbacks are not executed parallel.
  4414. *
  4415. * @param eventData The data to be sent to each callback
  4416. * @param mask is used to filter observers defaults to -1
  4417. * @param target defines the callback target (see EventState)
  4418. * @param currentTarget defines he current object in the bubbling phase
  4419. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4420. */
  4421. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4422. /**
  4423. * Notify a specific observer
  4424. * @param observer defines the observer to notify
  4425. * @param eventData defines the data to be sent to each callback
  4426. * @param mask is used to filter observers defaults to -1
  4427. */
  4428. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4429. /**
  4430. * Gets a boolean indicating if the observable has at least one observer
  4431. * @returns true is the Observable has at least one Observer registered
  4432. */
  4433. hasObservers(): boolean;
  4434. /**
  4435. * Clear the list of observers
  4436. */
  4437. clear(): void;
  4438. /**
  4439. * Clone the current observable
  4440. * @returns a new observable
  4441. */
  4442. clone(): Observable<T>;
  4443. /**
  4444. * Does this observable handles observer registered with a given mask
  4445. * @param mask defines the mask to be tested
  4446. * @return whether or not one observer registered with the given mask is handeled
  4447. **/
  4448. hasSpecificMask(mask?: number): boolean;
  4449. }
  4450. }
  4451. declare module BABYLON {
  4452. /**
  4453. * Class used to help managing file picking and drag'n'drop
  4454. * File Storage
  4455. */
  4456. export class FilesInputStore {
  4457. /**
  4458. * List of files ready to be loaded
  4459. */
  4460. static FilesToLoad: {
  4461. [key: string]: File;
  4462. };
  4463. }
  4464. }
  4465. declare module BABYLON {
  4466. /** Defines the cross module used constants to avoid circular dependncies */
  4467. export class Constants {
  4468. /** Defines that alpha blending is disabled */
  4469. static readonly ALPHA_DISABLE: number;
  4470. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4471. static readonly ALPHA_ADD: number;
  4472. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4473. static readonly ALPHA_COMBINE: number;
  4474. /** Defines that alpha blending to DEST - SRC * DEST */
  4475. static readonly ALPHA_SUBTRACT: number;
  4476. /** Defines that alpha blending to SRC * DEST */
  4477. static readonly ALPHA_MULTIPLY: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4479. static readonly ALPHA_MAXIMIZED: number;
  4480. /** Defines that alpha blending to SRC + DEST */
  4481. static readonly ALPHA_ONEONE: number;
  4482. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4483. static readonly ALPHA_PREMULTIPLIED: number;
  4484. /**
  4485. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4486. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4487. */
  4488. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4489. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4490. static readonly ALPHA_INTERPOLATE: number;
  4491. /**
  4492. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4493. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4494. */
  4495. static readonly ALPHA_SCREENMODE: number;
  4496. /** Defines that the ressource is not delayed*/
  4497. static readonly DELAYLOADSTATE_NONE: number;
  4498. /** Defines that the ressource was successfully delay loaded */
  4499. static readonly DELAYLOADSTATE_LOADED: number;
  4500. /** Defines that the ressource is currently delay loading */
  4501. static readonly DELAYLOADSTATE_LOADING: number;
  4502. /** Defines that the ressource is delayed and has not started loading */
  4503. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4504. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4505. static readonly NEVER: number;
  4506. /** 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 */
  4507. static readonly ALWAYS: number;
  4508. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4509. static readonly LESS: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4511. static readonly EQUAL: number;
  4512. /** 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 */
  4513. static readonly LEQUAL: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4515. static readonly GREATER: number;
  4516. /** 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 */
  4517. static readonly GEQUAL: number;
  4518. /** 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 */
  4519. static readonly NOTEQUAL: number;
  4520. /** Passed to stencilOperation to specify that stencil value must be kept */
  4521. static readonly KEEP: number;
  4522. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4523. static readonly REPLACE: number;
  4524. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4525. static readonly INCR: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4527. static readonly DECR: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4529. static readonly INVERT: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4531. static readonly INCR_WRAP: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4533. static readonly DECR_WRAP: number;
  4534. /** Texture is not repeating outside of 0..1 UVs */
  4535. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4536. /** Texture is repeating outside of 0..1 UVs */
  4537. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4538. /** Texture is repeating and mirrored */
  4539. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4540. /** ALPHA */
  4541. static readonly TEXTUREFORMAT_ALPHA: number;
  4542. /** LUMINANCE */
  4543. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4544. /** LUMINANCE_ALPHA */
  4545. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4546. /** RGB */
  4547. static readonly TEXTUREFORMAT_RGB: number;
  4548. /** RGBA */
  4549. static readonly TEXTUREFORMAT_RGBA: number;
  4550. /** RED */
  4551. static readonly TEXTUREFORMAT_RED: number;
  4552. /** RED (2nd reference) */
  4553. static readonly TEXTUREFORMAT_R: number;
  4554. /** RG */
  4555. static readonly TEXTUREFORMAT_RG: number;
  4556. /** RED_INTEGER */
  4557. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4558. /** RED_INTEGER (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4560. /** RG_INTEGER */
  4561. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4562. /** RGB_INTEGER */
  4563. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4564. /** RGBA_INTEGER */
  4565. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4566. /** UNSIGNED_BYTE */
  4567. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4568. /** UNSIGNED_BYTE (2nd reference) */
  4569. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4570. /** FLOAT */
  4571. static readonly TEXTURETYPE_FLOAT: number;
  4572. /** HALF_FLOAT */
  4573. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4574. /** BYTE */
  4575. static readonly TEXTURETYPE_BYTE: number;
  4576. /** SHORT */
  4577. static readonly TEXTURETYPE_SHORT: number;
  4578. /** UNSIGNED_SHORT */
  4579. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4580. /** INT */
  4581. static readonly TEXTURETYPE_INT: number;
  4582. /** UNSIGNED_INT */
  4583. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4584. /** UNSIGNED_SHORT_4_4_4_4 */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4586. /** UNSIGNED_SHORT_5_5_5_1 */
  4587. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4588. /** UNSIGNED_SHORT_5_6_5 */
  4589. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4590. /** UNSIGNED_INT_2_10_10_10_REV */
  4591. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4592. /** UNSIGNED_INT_24_8 */
  4593. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4594. /** UNSIGNED_INT_10F_11F_11F_REV */
  4595. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4596. /** UNSIGNED_INT_5_9_9_9_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4598. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4599. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4600. /** nearest is mag = nearest and min = nearest and mip = linear */
  4601. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4602. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4603. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4604. /** Trilinear is mag = linear and min = linear and mip = linear */
  4605. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4612. /** mag = nearest and min = nearest and mip = nearest */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4614. /** mag = nearest and min = linear and mip = nearest */
  4615. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4616. /** mag = nearest and min = linear and mip = linear */
  4617. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = linear and mip = none */
  4619. static readonly TEXTURE_NEAREST_LINEAR: number;
  4620. /** mag = nearest and min = nearest and mip = none */
  4621. static readonly TEXTURE_NEAREST_NEAREST: number;
  4622. /** mag = linear and min = nearest and mip = nearest */
  4623. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4624. /** mag = linear and min = nearest and mip = linear */
  4625. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4626. /** mag = linear and min = linear and mip = none */
  4627. static readonly TEXTURE_LINEAR_LINEAR: number;
  4628. /** mag = linear and min = nearest and mip = none */
  4629. static readonly TEXTURE_LINEAR_NEAREST: number;
  4630. /** Explicit coordinates mode */
  4631. static readonly TEXTURE_EXPLICIT_MODE: number;
  4632. /** Spherical coordinates mode */
  4633. static readonly TEXTURE_SPHERICAL_MODE: number;
  4634. /** Planar coordinates mode */
  4635. static readonly TEXTURE_PLANAR_MODE: number;
  4636. /** Cubic coordinates mode */
  4637. static readonly TEXTURE_CUBIC_MODE: number;
  4638. /** Projection coordinates mode */
  4639. static readonly TEXTURE_PROJECTION_MODE: number;
  4640. /** Skybox coordinates mode */
  4641. static readonly TEXTURE_SKYBOX_MODE: number;
  4642. /** Inverse Cubic coordinates mode */
  4643. static readonly TEXTURE_INVCUBIC_MODE: number;
  4644. /** Equirectangular coordinates mode */
  4645. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4646. /** Equirectangular Fixed coordinates mode */
  4647. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4648. /** Equirectangular Fixed Mirrored coordinates mode */
  4649. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4650. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4651. static readonly SCALEMODE_FLOOR: number;
  4652. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4653. static readonly SCALEMODE_NEAREST: number;
  4654. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4655. static readonly SCALEMODE_CEILING: number;
  4656. /**
  4657. * The dirty texture flag value
  4658. */
  4659. static readonly MATERIAL_TextureDirtyFlag: number;
  4660. /**
  4661. * The dirty light flag value
  4662. */
  4663. static readonly MATERIAL_LightDirtyFlag: number;
  4664. /**
  4665. * The dirty fresnel flag value
  4666. */
  4667. static readonly MATERIAL_FresnelDirtyFlag: number;
  4668. /**
  4669. * The dirty attribute flag value
  4670. */
  4671. static readonly MATERIAL_AttributesDirtyFlag: number;
  4672. /**
  4673. * The dirty misc flag value
  4674. */
  4675. static readonly MATERIAL_MiscDirtyFlag: number;
  4676. /**
  4677. * The all dirty flag value
  4678. */
  4679. static readonly MATERIAL_AllDirtyFlag: number;
  4680. /**
  4681. * Returns the triangle fill mode
  4682. */
  4683. static readonly MATERIAL_TriangleFillMode: number;
  4684. /**
  4685. * Returns the wireframe mode
  4686. */
  4687. static readonly MATERIAL_WireFrameFillMode: number;
  4688. /**
  4689. * Returns the point fill mode
  4690. */
  4691. static readonly MATERIAL_PointFillMode: number;
  4692. /**
  4693. * Returns the point list draw mode
  4694. */
  4695. static readonly MATERIAL_PointListDrawMode: number;
  4696. /**
  4697. * Returns the line list draw mode
  4698. */
  4699. static readonly MATERIAL_LineListDrawMode: number;
  4700. /**
  4701. * Returns the line loop draw mode
  4702. */
  4703. static readonly MATERIAL_LineLoopDrawMode: number;
  4704. /**
  4705. * Returns the line strip draw mode
  4706. */
  4707. static readonly MATERIAL_LineStripDrawMode: number;
  4708. /**
  4709. * Returns the triangle strip draw mode
  4710. */
  4711. static readonly MATERIAL_TriangleStripDrawMode: number;
  4712. /**
  4713. * Returns the triangle fan draw mode
  4714. */
  4715. static readonly MATERIAL_TriangleFanDrawMode: number;
  4716. /**
  4717. * Stores the clock-wise side orientation
  4718. */
  4719. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4720. /**
  4721. * Stores the counter clock-wise side orientation
  4722. */
  4723. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4724. /**
  4725. * Nothing
  4726. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4727. */
  4728. static readonly ACTION_NothingTrigger: number;
  4729. /**
  4730. * On pick
  4731. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4732. */
  4733. static readonly ACTION_OnPickTrigger: number;
  4734. /**
  4735. * On left pick
  4736. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4737. */
  4738. static readonly ACTION_OnLeftPickTrigger: number;
  4739. /**
  4740. * On right pick
  4741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4742. */
  4743. static readonly ACTION_OnRightPickTrigger: number;
  4744. /**
  4745. * On center pick
  4746. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4747. */
  4748. static readonly ACTION_OnCenterPickTrigger: number;
  4749. /**
  4750. * On pick down
  4751. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4752. */
  4753. static readonly ACTION_OnPickDownTrigger: number;
  4754. /**
  4755. * On double pick
  4756. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4757. */
  4758. static readonly ACTION_OnDoublePickTrigger: number;
  4759. /**
  4760. * On pick up
  4761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4762. */
  4763. static readonly ACTION_OnPickUpTrigger: number;
  4764. /**
  4765. * On pick out.
  4766. * This trigger will only be raised if you also declared a OnPickDown
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickOutTrigger: number;
  4770. /**
  4771. * On long press
  4772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4773. */
  4774. static readonly ACTION_OnLongPressTrigger: number;
  4775. /**
  4776. * On pointer over
  4777. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4778. */
  4779. static readonly ACTION_OnPointerOverTrigger: number;
  4780. /**
  4781. * On pointer out
  4782. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4783. */
  4784. static readonly ACTION_OnPointerOutTrigger: number;
  4785. /**
  4786. * On every frame
  4787. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4788. */
  4789. static readonly ACTION_OnEveryFrameTrigger: number;
  4790. /**
  4791. * On intersection enter
  4792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4793. */
  4794. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4795. /**
  4796. * On intersection exit
  4797. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4798. */
  4799. static readonly ACTION_OnIntersectionExitTrigger: number;
  4800. /**
  4801. * On key down
  4802. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4803. */
  4804. static readonly ACTION_OnKeyDownTrigger: number;
  4805. /**
  4806. * On key up
  4807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4808. */
  4809. static readonly ACTION_OnKeyUpTrigger: number;
  4810. /**
  4811. * Billboard mode will only apply to Y axis
  4812. */
  4813. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4814. /**
  4815. * Billboard mode will apply to all axes
  4816. */
  4817. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4818. /**
  4819. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4820. */
  4821. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4822. /**
  4823. * Gets or sets base Assets URL
  4824. */
  4825. static readonly PARTICLES_BaseAssetsUrl: string;
  4826. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4827. * Test order :
  4828. * Is the bounding sphere outside the frustum ?
  4829. * If not, are the bounding box vertices outside the frustum ?
  4830. * It not, then the cullable object is in the frustum.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4833. /** Culling strategy : Bounding Sphere Only.
  4834. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4835. * It's also less accurate than the standard because some not visible objects can still be selected.
  4836. * Test : is the bounding sphere outside the frustum ?
  4837. * If not, then the cullable object is in the frustum.
  4838. */
  4839. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4840. /** Culling strategy : Optimistic Inclusion.
  4841. * This in an inclusion test first, then the standard exclusion test.
  4842. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4843. * 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.
  4844. * Anyway, it's as accurate as the standard strategy.
  4845. * Test :
  4846. * Is the cullable object bounding sphere center in the frustum ?
  4847. * If not, apply the default culling strategy.
  4848. */
  4849. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4850. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4851. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4852. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4853. * 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.
  4854. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4855. * Test :
  4856. * Is the cullable object bounding sphere center in the frustum ?
  4857. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4858. */
  4859. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4860. /**
  4861. * No logging while loading
  4862. */
  4863. static readonly SCENELOADER_NO_LOGGING: number;
  4864. /**
  4865. * Minimal logging while loading
  4866. */
  4867. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4868. /**
  4869. * Summary logging while loading
  4870. */
  4871. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4872. /**
  4873. * Detailled logging while loading
  4874. */
  4875. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4876. }
  4877. }
  4878. declare module BABYLON {
  4879. /**
  4880. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4881. * Babylon.js
  4882. */
  4883. export class DomManagement {
  4884. /**
  4885. * Checks if the window object exists
  4886. * @returns true if the window object exists
  4887. */
  4888. static IsWindowObjectExist(): boolean;
  4889. /**
  4890. * Extracts text content from a DOM element hierarchy
  4891. * @param element defines the root element
  4892. * @returns a string
  4893. */
  4894. static GetDOMTextContent(element: HTMLElement): string;
  4895. }
  4896. }
  4897. declare module BABYLON {
  4898. /**
  4899. * Logger used througouht the application to allow configuration of
  4900. * the log level required for the messages.
  4901. */
  4902. export class Logger {
  4903. /**
  4904. * No log
  4905. */
  4906. static readonly NoneLogLevel: number;
  4907. /**
  4908. * Only message logs
  4909. */
  4910. static readonly MessageLogLevel: number;
  4911. /**
  4912. * Only warning logs
  4913. */
  4914. static readonly WarningLogLevel: number;
  4915. /**
  4916. * Only error logs
  4917. */
  4918. static readonly ErrorLogLevel: number;
  4919. /**
  4920. * All logs
  4921. */
  4922. static readonly AllLogLevel: number;
  4923. private static _LogCache;
  4924. /**
  4925. * Gets a value indicating the number of loading errors
  4926. * @ignorenaming
  4927. */
  4928. static errorsCount: number;
  4929. /**
  4930. * Callback called when a new log is added
  4931. */
  4932. static OnNewCacheEntry: (entry: string) => void;
  4933. private static _AddLogEntry;
  4934. private static _FormatMessage;
  4935. private static _LogDisabled;
  4936. private static _LogEnabled;
  4937. private static _WarnDisabled;
  4938. private static _WarnEnabled;
  4939. private static _ErrorDisabled;
  4940. private static _ErrorEnabled;
  4941. /**
  4942. * Log a message to the console
  4943. */
  4944. static Log: (message: string) => void;
  4945. /**
  4946. * Write a warning message to the console
  4947. */
  4948. static Warn: (message: string) => void;
  4949. /**
  4950. * Write an error message to the console
  4951. */
  4952. static Error: (message: string) => void;
  4953. /**
  4954. * Gets current log cache (list of logs)
  4955. */
  4956. static readonly LogCache: string;
  4957. /**
  4958. * Clears the log cache
  4959. */
  4960. static ClearLogCache(): void;
  4961. /**
  4962. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4963. */
  4964. static LogLevels: number;
  4965. }
  4966. }
  4967. declare module BABYLON {
  4968. /** @hidden */
  4969. export class _TypeStore {
  4970. /** @hidden */
  4971. static RegisteredTypes: {
  4972. [key: string]: Object;
  4973. };
  4974. /** @hidden */
  4975. static GetClass(fqdn: string): any;
  4976. }
  4977. }
  4978. declare module BABYLON {
  4979. /**
  4980. * Class containing a set of static utilities functions for deep copy.
  4981. */
  4982. export class DeepCopier {
  4983. /**
  4984. * Tries to copy an object by duplicating every property
  4985. * @param source defines the source object
  4986. * @param destination defines the target object
  4987. * @param doNotCopyList defines a list of properties to avoid
  4988. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4989. */
  4990. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4991. }
  4992. }
  4993. declare module BABYLON {
  4994. /**
  4995. * Class containing a set of static utilities functions for precision date
  4996. */
  4997. export class PrecisionDate {
  4998. /**
  4999. * Gets either window.performance.now() if supported or Date.now() else
  5000. */
  5001. static readonly Now: number;
  5002. }
  5003. }
  5004. declare module BABYLON {
  5005. /** @hidden */
  5006. export class _DevTools {
  5007. static WarnImport(name: string): string;
  5008. }
  5009. }
  5010. declare module BABYLON {
  5011. /**
  5012. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5013. */
  5014. export class WebRequest {
  5015. private _xhr;
  5016. /**
  5017. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5018. * i.e. when loading files, where the server/service expects an Authorization header
  5019. */
  5020. static CustomRequestHeaders: {
  5021. [key: string]: string;
  5022. };
  5023. /**
  5024. * Add callback functions in this array to update all the requests before they get sent to the network
  5025. */
  5026. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5027. private _injectCustomRequestHeaders;
  5028. /**
  5029. * Gets or sets a function to be called when loading progress changes
  5030. */
  5031. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5032. /**
  5033. * Returns client's state
  5034. */
  5035. readonly readyState: number;
  5036. /**
  5037. * Returns client's status
  5038. */
  5039. readonly status: number;
  5040. /**
  5041. * Returns client's status as a text
  5042. */
  5043. readonly statusText: string;
  5044. /**
  5045. * Returns client's response
  5046. */
  5047. readonly response: any;
  5048. /**
  5049. * Returns client's response url
  5050. */
  5051. readonly responseURL: string;
  5052. /**
  5053. * Returns client's response as text
  5054. */
  5055. readonly responseText: string;
  5056. /**
  5057. * Gets or sets the expected response type
  5058. */
  5059. responseType: XMLHttpRequestResponseType;
  5060. /** @hidden */
  5061. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5062. /** @hidden */
  5063. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5064. /**
  5065. * Cancels any network activity
  5066. */
  5067. abort(): void;
  5068. /**
  5069. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5070. * @param body defines an optional request body
  5071. */
  5072. send(body?: Document | BodyInit | null): void;
  5073. /**
  5074. * Sets the request method, request URL
  5075. * @param method defines the method to use (GET, POST, etc..)
  5076. * @param url defines the url to connect with
  5077. */
  5078. open(method: string, url: string): void;
  5079. }
  5080. }
  5081. declare module BABYLON {
  5082. /**
  5083. * Class used to evalaute queries containing `and` and `or` operators
  5084. */
  5085. export class AndOrNotEvaluator {
  5086. /**
  5087. * Evaluate a query
  5088. * @param query defines the query to evaluate
  5089. * @param evaluateCallback defines the callback used to filter result
  5090. * @returns true if the query matches
  5091. */
  5092. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5093. private static _HandleParenthesisContent;
  5094. private static _SimplifyNegation;
  5095. }
  5096. }
  5097. declare module BABYLON {
  5098. /**
  5099. * Class used to store custom tags
  5100. */
  5101. export class Tags {
  5102. /**
  5103. * Adds support for tags on the given object
  5104. * @param obj defines the object to use
  5105. */
  5106. static EnableFor(obj: any): void;
  5107. /**
  5108. * Removes tags support
  5109. * @param obj defines the object to use
  5110. */
  5111. static DisableFor(obj: any): void;
  5112. /**
  5113. * Gets a boolean indicating if the given object has tags
  5114. * @param obj defines the object to use
  5115. * @returns a boolean
  5116. */
  5117. static HasTags(obj: any): boolean;
  5118. /**
  5119. * Gets the tags available on a given object
  5120. * @param obj defines the object to use
  5121. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5122. * @returns the tags
  5123. */
  5124. static GetTags(obj: any, asString?: boolean): any;
  5125. /**
  5126. * Adds tags to an object
  5127. * @param obj defines the object to use
  5128. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5129. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5130. */
  5131. static AddTagsTo(obj: any, tagsString: string): void;
  5132. /**
  5133. * @hidden
  5134. */ private static _AddTagTo(obj: any, tag: string): void;
  5135. /**
  5136. * Removes specific tags from a specific object
  5137. * @param obj defines the object to use
  5138. * @param tagsString defines the tags to remove
  5139. */
  5140. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5141. /**
  5142. * @hidden
  5143. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5144. /**
  5145. * Defines if tags hosted on an object match a given query
  5146. * @param obj defines the object to use
  5147. * @param tagsQuery defines the tag query
  5148. * @returns a boolean
  5149. */
  5150. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5151. }
  5152. }
  5153. declare module BABYLON {
  5154. /**
  5155. * Manages the defines for the Material
  5156. */
  5157. export class MaterialDefines {
  5158. /** @hidden */
  5159. protected _keys: string[];
  5160. private _isDirty;
  5161. /** @hidden */ private _renderId: number;
  5162. /** @hidden */ private _areLightsDirty: boolean;
  5163. /** @hidden */ private _areAttributesDirty: boolean;
  5164. /** @hidden */ private _areTexturesDirty: boolean;
  5165. /** @hidden */ private _areFresnelDirty: boolean;
  5166. /** @hidden */ private _areMiscDirty: boolean;
  5167. /** @hidden */ private _areImageProcessingDirty: boolean;
  5168. /** @hidden */ private _normals: boolean;
  5169. /** @hidden */ private _uvs: boolean;
  5170. /** @hidden */ private _needNormals: boolean;
  5171. /** @hidden */ private _needUVs: boolean;
  5172. [id: string]: any;
  5173. /**
  5174. * Specifies if the material needs to be re-calculated
  5175. */
  5176. readonly isDirty: boolean;
  5177. /**
  5178. * Marks the material to indicate that it has been re-calculated
  5179. */
  5180. markAsProcessed(): void;
  5181. /**
  5182. * Marks the material to indicate that it needs to be re-calculated
  5183. */
  5184. markAsUnprocessed(): void;
  5185. /**
  5186. * Marks the material to indicate all of its defines need to be re-calculated
  5187. */
  5188. markAllAsDirty(): void;
  5189. /**
  5190. * Marks the material to indicate that image processing needs to be re-calculated
  5191. */
  5192. markAsImageProcessingDirty(): void;
  5193. /**
  5194. * Marks the material to indicate the lights need to be re-calculated
  5195. */
  5196. markAsLightDirty(): void;
  5197. /**
  5198. * Marks the attribute state as changed
  5199. */
  5200. markAsAttributesDirty(): void;
  5201. /**
  5202. * Marks the texture state as changed
  5203. */
  5204. markAsTexturesDirty(): void;
  5205. /**
  5206. * Marks the fresnel state as changed
  5207. */
  5208. markAsFresnelDirty(): void;
  5209. /**
  5210. * Marks the misc state as changed
  5211. */
  5212. markAsMiscDirty(): void;
  5213. /**
  5214. * Rebuilds the material defines
  5215. */
  5216. rebuild(): void;
  5217. /**
  5218. * Specifies if two material defines are equal
  5219. * @param other - A material define instance to compare to
  5220. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5221. */
  5222. isEqual(other: MaterialDefines): boolean;
  5223. /**
  5224. * Clones this instance's defines to another instance
  5225. * @param other - material defines to clone values to
  5226. */
  5227. cloneTo(other: MaterialDefines): void;
  5228. /**
  5229. * Resets the material define values
  5230. */
  5231. reset(): void;
  5232. /**
  5233. * Converts the material define values to a string
  5234. * @returns - String of material define information
  5235. */
  5236. toString(): string;
  5237. }
  5238. }
  5239. declare module BABYLON {
  5240. /**
  5241. * Class used to store and describe the pipeline context associated with an effect
  5242. */
  5243. export interface IPipelineContext {
  5244. /**
  5245. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5246. */
  5247. isAsync: boolean;
  5248. /**
  5249. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5250. */
  5251. isReady: boolean;
  5252. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5253. }
  5254. }
  5255. declare module BABYLON {
  5256. /**
  5257. * Class used to store gfx data (like WebGLBuffer)
  5258. */
  5259. export class DataBuffer {
  5260. /**
  5261. * Gets or sets the number of objects referencing this buffer
  5262. */
  5263. references: number;
  5264. /** Gets or sets the size of the underlying buffer */
  5265. capacity: number;
  5266. /**
  5267. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5268. */
  5269. is32Bits: boolean;
  5270. /**
  5271. * Gets the underlying buffer
  5272. */
  5273. readonly underlyingResource: any;
  5274. }
  5275. }
  5276. declare module BABYLON {
  5277. /**
  5278. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5279. */
  5280. export class PerformanceMonitor {
  5281. private _enabled;
  5282. private _rollingFrameTime;
  5283. private _lastFrameTimeMs;
  5284. /**
  5285. * constructor
  5286. * @param frameSampleSize The number of samples required to saturate the sliding window
  5287. */
  5288. constructor(frameSampleSize?: number);
  5289. /**
  5290. * Samples current frame
  5291. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5292. */
  5293. sampleFrame(timeMs?: number): void;
  5294. /**
  5295. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5296. */
  5297. readonly averageFrameTime: number;
  5298. /**
  5299. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5300. */
  5301. readonly averageFrameTimeVariance: number;
  5302. /**
  5303. * Returns the frame time of the most recent frame
  5304. */
  5305. readonly instantaneousFrameTime: number;
  5306. /**
  5307. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5308. */
  5309. readonly averageFPS: number;
  5310. /**
  5311. * Returns the average framerate in frames per second using the most recent frame time
  5312. */
  5313. readonly instantaneousFPS: number;
  5314. /**
  5315. * Returns true if enough samples have been taken to completely fill the sliding window
  5316. */
  5317. readonly isSaturated: boolean;
  5318. /**
  5319. * Enables contributions to the sliding window sample set
  5320. */
  5321. enable(): void;
  5322. /**
  5323. * Disables contributions to the sliding window sample set
  5324. * Samples will not be interpolated over the disabled period
  5325. */
  5326. disable(): void;
  5327. /**
  5328. * Returns true if sampling is enabled
  5329. */
  5330. readonly isEnabled: boolean;
  5331. /**
  5332. * Resets performance monitor
  5333. */
  5334. reset(): void;
  5335. }
  5336. /**
  5337. * RollingAverage
  5338. *
  5339. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5340. */
  5341. export class RollingAverage {
  5342. /**
  5343. * Current average
  5344. */
  5345. average: number;
  5346. /**
  5347. * Current variance
  5348. */
  5349. variance: number;
  5350. protected _samples: Array<number>;
  5351. protected _sampleCount: number;
  5352. protected _pos: number;
  5353. protected _m2: number;
  5354. /**
  5355. * constructor
  5356. * @param length The number of samples required to saturate the sliding window
  5357. */
  5358. constructor(length: number);
  5359. /**
  5360. * Adds a sample to the sample set
  5361. * @param v The sample value
  5362. */
  5363. add(v: number): void;
  5364. /**
  5365. * Returns previously added values or null if outside of history or outside the sliding window domain
  5366. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5367. * @return Value previously recorded with add() or null if outside of range
  5368. */
  5369. history(i: number): number;
  5370. /**
  5371. * Returns true if enough samples have been taken to completely fill the sliding window
  5372. * @return true if sample-set saturated
  5373. */
  5374. isSaturated(): boolean;
  5375. /**
  5376. * Resets the rolling average (equivalent to 0 samples taken so far)
  5377. */
  5378. reset(): void;
  5379. /**
  5380. * Wraps a value around the sample range boundaries
  5381. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5382. * @return Wrapped position in sample range
  5383. */
  5384. protected _wrapPosition(i: number): number;
  5385. }
  5386. }
  5387. declare module BABYLON {
  5388. /**
  5389. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5390. * The underlying implementation relies on an associative array to ensure the best performances.
  5391. * The value can be anything including 'null' but except 'undefined'
  5392. */
  5393. export class StringDictionary<T> {
  5394. /**
  5395. * This will clear this dictionary and copy the content from the 'source' one.
  5396. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5397. * @param source the dictionary to take the content from and copy to this dictionary
  5398. */
  5399. copyFrom(source: StringDictionary<T>): void;
  5400. /**
  5401. * Get a value based from its key
  5402. * @param key the given key to get the matching value from
  5403. * @return the value if found, otherwise undefined is returned
  5404. */
  5405. get(key: string): T | undefined;
  5406. /**
  5407. * Get a value from its key or add it if it doesn't exist.
  5408. * This method will ensure you that a given key/data will be present in the dictionary.
  5409. * @param key the given key to get the matching value from
  5410. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5411. * The factory will only be invoked if there's no data for the given key.
  5412. * @return the value corresponding to the key.
  5413. */
  5414. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5415. /**
  5416. * Get a value from its key if present in the dictionary otherwise add it
  5417. * @param key the key to get the value from
  5418. * @param val if there's no such key/value pair in the dictionary add it with this value
  5419. * @return the value corresponding to the key
  5420. */
  5421. getOrAdd(key: string, val: T): T;
  5422. /**
  5423. * Check if there's a given key in the dictionary
  5424. * @param key the key to check for
  5425. * @return true if the key is present, false otherwise
  5426. */
  5427. contains(key: string): boolean;
  5428. /**
  5429. * Add a new key and its corresponding value
  5430. * @param key the key to add
  5431. * @param value the value corresponding to the key
  5432. * @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
  5433. */
  5434. add(key: string, value: T): boolean;
  5435. /**
  5436. * Update a specific value associated to a key
  5437. * @param key defines the key to use
  5438. * @param value defines the value to store
  5439. * @returns true if the value was updated (or false if the key was not found)
  5440. */
  5441. set(key: string, value: T): boolean;
  5442. /**
  5443. * Get the element of the given key and remove it from the dictionary
  5444. * @param key defines the key to search
  5445. * @returns the value associated with the key or null if not found
  5446. */
  5447. getAndRemove(key: string): Nullable<T>;
  5448. /**
  5449. * Remove a key/value from the dictionary.
  5450. * @param key the key to remove
  5451. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5452. */
  5453. remove(key: string): boolean;
  5454. /**
  5455. * Clear the whole content of the dictionary
  5456. */
  5457. clear(): void;
  5458. /**
  5459. * Gets the current count
  5460. */
  5461. readonly count: number;
  5462. /**
  5463. * Execute a callback on each key/val of the dictionary.
  5464. * Note that you can remove any element in this dictionary in the callback implementation
  5465. * @param callback the callback to execute on a given key/value pair
  5466. */
  5467. forEach(callback: (key: string, val: T) => void): void;
  5468. /**
  5469. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5470. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5471. * Note that you can remove any element in this dictionary in the callback implementation
  5472. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5473. * @returns the first item
  5474. */
  5475. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5476. private _count;
  5477. private _data;
  5478. }
  5479. }
  5480. declare module BABYLON {
  5481. /**
  5482. * Helper class that provides a small promise polyfill
  5483. */
  5484. export class PromisePolyfill {
  5485. /**
  5486. * Static function used to check if the polyfill is required
  5487. * If this is the case then the function will inject the polyfill to window.Promise
  5488. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5489. */
  5490. static Apply(force?: boolean): void;
  5491. }
  5492. }
  5493. declare module BABYLON {
  5494. /**
  5495. * Class used to store data that will be store in GPU memory
  5496. */
  5497. export class Buffer {
  5498. private _engine;
  5499. private _buffer;
  5500. /** @hidden */ private _data: Nullable<DataArray>;
  5501. private _updatable;
  5502. private _instanced;
  5503. /**
  5504. * Gets the byte stride.
  5505. */
  5506. readonly byteStride: number;
  5507. /**
  5508. * Constructor
  5509. * @param engine the engine
  5510. * @param data the data to use for this buffer
  5511. * @param updatable whether the data is updatable
  5512. * @param stride the stride (optional)
  5513. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5514. * @param instanced whether the buffer is instanced (optional)
  5515. * @param useBytes set to true if the stride in in bytes (optional)
  5516. */
  5517. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5518. /**
  5519. * Create a new VertexBuffer based on the current buffer
  5520. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5521. * @param offset defines offset in the buffer (0 by default)
  5522. * @param size defines the size in floats of attributes (position is 3 for instance)
  5523. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5524. * @param instanced defines if the vertex buffer contains indexed data
  5525. * @param useBytes defines if the offset and stride are in bytes
  5526. * @returns the new vertex buffer
  5527. */
  5528. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5529. /**
  5530. * Gets a boolean indicating if the Buffer is updatable?
  5531. * @returns true if the buffer is updatable
  5532. */
  5533. isUpdatable(): boolean;
  5534. /**
  5535. * Gets current buffer's data
  5536. * @returns a DataArray or null
  5537. */
  5538. getData(): Nullable<DataArray>;
  5539. /**
  5540. * Gets underlying native buffer
  5541. * @returns underlying native buffer
  5542. */
  5543. getBuffer(): Nullable<DataBuffer>;
  5544. /**
  5545. * Gets the stride in float32 units (i.e. byte stride / 4).
  5546. * May not be an integer if the byte stride is not divisible by 4.
  5547. * DEPRECATED. Use byteStride instead.
  5548. * @returns the stride in float32 units
  5549. */
  5550. getStrideSize(): number;
  5551. /**
  5552. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5553. * @param data defines the data to store
  5554. */
  5555. create(data?: Nullable<DataArray>): void;
  5556. /** @hidden */ private _rebuild(): void;
  5557. /**
  5558. * Update current buffer data
  5559. * @param data defines the data to store
  5560. */
  5561. update(data: DataArray): void;
  5562. /**
  5563. * Updates the data directly.
  5564. * @param data the new data
  5565. * @param offset the new offset
  5566. * @param vertexCount the vertex count (optional)
  5567. * @param useBytes set to true if the offset is in bytes
  5568. */
  5569. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5570. /**
  5571. * Release all resources
  5572. */
  5573. dispose(): void;
  5574. }
  5575. /**
  5576. * Specialized buffer used to store vertex data
  5577. */
  5578. export class VertexBuffer {
  5579. /** @hidden */ private _buffer: Buffer;
  5580. private _kind;
  5581. private _size;
  5582. private _ownsBuffer;
  5583. private _instanced;
  5584. private _instanceDivisor;
  5585. /**
  5586. * The byte type.
  5587. */
  5588. static readonly BYTE: number;
  5589. /**
  5590. * The unsigned byte type.
  5591. */
  5592. static readonly UNSIGNED_BYTE: number;
  5593. /**
  5594. * The short type.
  5595. */
  5596. static readonly SHORT: number;
  5597. /**
  5598. * The unsigned short type.
  5599. */
  5600. static readonly UNSIGNED_SHORT: number;
  5601. /**
  5602. * The integer type.
  5603. */
  5604. static readonly INT: number;
  5605. /**
  5606. * The unsigned integer type.
  5607. */
  5608. static readonly UNSIGNED_INT: number;
  5609. /**
  5610. * The float type.
  5611. */
  5612. static readonly FLOAT: number;
  5613. /**
  5614. * Gets or sets the instance divisor when in instanced mode
  5615. */
  5616. instanceDivisor: number;
  5617. /**
  5618. * Gets the byte stride.
  5619. */
  5620. readonly byteStride: number;
  5621. /**
  5622. * Gets the byte offset.
  5623. */
  5624. readonly byteOffset: number;
  5625. /**
  5626. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5627. */
  5628. readonly normalized: boolean;
  5629. /**
  5630. * Gets the data type of each component in the array.
  5631. */
  5632. readonly type: number;
  5633. /**
  5634. * Constructor
  5635. * @param engine the engine
  5636. * @param data the data to use for this vertex buffer
  5637. * @param kind the vertex buffer kind
  5638. * @param updatable whether the data is updatable
  5639. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5640. * @param stride the stride (optional)
  5641. * @param instanced whether the buffer is instanced (optional)
  5642. * @param offset the offset of the data (optional)
  5643. * @param size the number of components (optional)
  5644. * @param type the type of the component (optional)
  5645. * @param normalized whether the data contains normalized data (optional)
  5646. * @param useBytes set to true if stride and offset are in bytes (optional)
  5647. */
  5648. 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);
  5649. /** @hidden */ private _rebuild(): void;
  5650. /**
  5651. * Returns the kind of the VertexBuffer (string)
  5652. * @returns a string
  5653. */
  5654. getKind(): string;
  5655. /**
  5656. * Gets a boolean indicating if the VertexBuffer is updatable?
  5657. * @returns true if the buffer is updatable
  5658. */
  5659. isUpdatable(): boolean;
  5660. /**
  5661. * Gets current buffer's data
  5662. * @returns a DataArray or null
  5663. */
  5664. getData(): Nullable<DataArray>;
  5665. /**
  5666. * Gets underlying native buffer
  5667. * @returns underlying native buffer
  5668. */
  5669. getBuffer(): Nullable<DataBuffer>;
  5670. /**
  5671. * Gets the stride in float32 units (i.e. byte stride / 4).
  5672. * May not be an integer if the byte stride is not divisible by 4.
  5673. * DEPRECATED. Use byteStride instead.
  5674. * @returns the stride in float32 units
  5675. */
  5676. getStrideSize(): number;
  5677. /**
  5678. * Returns the offset as a multiple of the type byte length.
  5679. * DEPRECATED. Use byteOffset instead.
  5680. * @returns the offset in bytes
  5681. */
  5682. getOffset(): number;
  5683. /**
  5684. * Returns the number of components per vertex attribute (integer)
  5685. * @returns the size in float
  5686. */
  5687. getSize(): number;
  5688. /**
  5689. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5690. * @returns true if this buffer is instanced
  5691. */
  5692. getIsInstanced(): boolean;
  5693. /**
  5694. * Returns the instancing divisor, zero for non-instanced (integer).
  5695. * @returns a number
  5696. */
  5697. getInstanceDivisor(): number;
  5698. /**
  5699. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5700. * @param data defines the data to store
  5701. */
  5702. create(data?: DataArray): void;
  5703. /**
  5704. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5705. * This function will create a new buffer if the current one is not updatable
  5706. * @param data defines the data to store
  5707. */
  5708. update(data: DataArray): void;
  5709. /**
  5710. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5711. * Returns the directly updated WebGLBuffer.
  5712. * @param data the new data
  5713. * @param offset the new offset
  5714. * @param useBytes set to true if the offset is in bytes
  5715. */
  5716. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5717. /**
  5718. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5719. */
  5720. dispose(): void;
  5721. /**
  5722. * Enumerates each value of this vertex buffer as numbers.
  5723. * @param count the number of values to enumerate
  5724. * @param callback the callback function called for each value
  5725. */
  5726. forEach(count: number, callback: (value: number, index: number) => void): void;
  5727. /**
  5728. * Positions
  5729. */
  5730. static readonly PositionKind: string;
  5731. /**
  5732. * Normals
  5733. */
  5734. static readonly NormalKind: string;
  5735. /**
  5736. * Tangents
  5737. */
  5738. static readonly TangentKind: string;
  5739. /**
  5740. * Texture coordinates
  5741. */
  5742. static readonly UVKind: string;
  5743. /**
  5744. * Texture coordinates 2
  5745. */
  5746. static readonly UV2Kind: string;
  5747. /**
  5748. * Texture coordinates 3
  5749. */
  5750. static readonly UV3Kind: string;
  5751. /**
  5752. * Texture coordinates 4
  5753. */
  5754. static readonly UV4Kind: string;
  5755. /**
  5756. * Texture coordinates 5
  5757. */
  5758. static readonly UV5Kind: string;
  5759. /**
  5760. * Texture coordinates 6
  5761. */
  5762. static readonly UV6Kind: string;
  5763. /**
  5764. * Colors
  5765. */
  5766. static readonly ColorKind: string;
  5767. /**
  5768. * Matrix indices (for bones)
  5769. */
  5770. static readonly MatricesIndicesKind: string;
  5771. /**
  5772. * Matrix weights (for bones)
  5773. */
  5774. static readonly MatricesWeightsKind: string;
  5775. /**
  5776. * Additional matrix indices (for bones)
  5777. */
  5778. static readonly MatricesIndicesExtraKind: string;
  5779. /**
  5780. * Additional matrix weights (for bones)
  5781. */
  5782. static readonly MatricesWeightsExtraKind: string;
  5783. /**
  5784. * Deduces the stride given a kind.
  5785. * @param kind The kind string to deduce
  5786. * @returns The deduced stride
  5787. */
  5788. static DeduceStride(kind: string): number;
  5789. /**
  5790. * Gets the byte length of the given type.
  5791. * @param type the type
  5792. * @returns the number of bytes
  5793. */
  5794. static GetTypeByteLength(type: number): number;
  5795. /**
  5796. * Enumerates each value of the given parameters as numbers.
  5797. * @param data the data to enumerate
  5798. * @param byteOffset the byte offset of the data
  5799. * @param byteStride the byte stride of the data
  5800. * @param componentCount the number of components per element
  5801. * @param componentType the type of the component
  5802. * @param count the total number of components
  5803. * @param normalized whether the data is normalized
  5804. * @param callback the callback function called for each value
  5805. */
  5806. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5807. private static _GetFloatValue;
  5808. }
  5809. }
  5810. declare module BABYLON {
  5811. /**
  5812. * Class representing spherical harmonics coefficients to the 3rd degree
  5813. */
  5814. export class SphericalHarmonics {
  5815. /**
  5816. * Defines whether or not the harmonics have been prescaled for rendering.
  5817. */
  5818. preScaled: boolean;
  5819. /**
  5820. * The l0,0 coefficients of the spherical harmonics
  5821. */
  5822. l00: Vector3;
  5823. /**
  5824. * The l1,-1 coefficients of the spherical harmonics
  5825. */
  5826. l1_1: Vector3;
  5827. /**
  5828. * The l1,0 coefficients of the spherical harmonics
  5829. */
  5830. l10: Vector3;
  5831. /**
  5832. * The l1,1 coefficients of the spherical harmonics
  5833. */
  5834. l11: Vector3;
  5835. /**
  5836. * The l2,-2 coefficients of the spherical harmonics
  5837. */
  5838. l2_2: Vector3;
  5839. /**
  5840. * The l2,-1 coefficients of the spherical harmonics
  5841. */
  5842. l2_1: Vector3;
  5843. /**
  5844. * The l2,0 coefficients of the spherical harmonics
  5845. */
  5846. l20: Vector3;
  5847. /**
  5848. * The l2,1 coefficients of the spherical harmonics
  5849. */
  5850. l21: Vector3;
  5851. /**
  5852. * The l2,2 coefficients of the spherical harmonics
  5853. */
  5854. l22: Vector3;
  5855. /**
  5856. * Adds a light to the spherical harmonics
  5857. * @param direction the direction of the light
  5858. * @param color the color of the light
  5859. * @param deltaSolidAngle the delta solid angle of the light
  5860. */
  5861. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5862. /**
  5863. * Scales the spherical harmonics by the given amount
  5864. * @param scale the amount to scale
  5865. */
  5866. scaleInPlace(scale: number): void;
  5867. /**
  5868. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5869. *
  5870. * ```
  5871. * E_lm = A_l * L_lm
  5872. * ```
  5873. *
  5874. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5875. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5876. * the scaling factors are given in equation 9.
  5877. */
  5878. convertIncidentRadianceToIrradiance(): void;
  5879. /**
  5880. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5881. *
  5882. * ```
  5883. * L = (1/pi) * E * rho
  5884. * ```
  5885. *
  5886. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5887. */
  5888. convertIrradianceToLambertianRadiance(): void;
  5889. /**
  5890. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5891. * required operations at run time.
  5892. *
  5893. * This is simply done by scaling back the SH with Ylm constants parameter.
  5894. * The trigonometric part being applied by the shader at run time.
  5895. */
  5896. preScaleForRendering(): void;
  5897. /**
  5898. * Constructs a spherical harmonics from an array.
  5899. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5900. * @returns the spherical harmonics
  5901. */
  5902. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5903. /**
  5904. * Gets the spherical harmonics from polynomial
  5905. * @param polynomial the spherical polynomial
  5906. * @returns the spherical harmonics
  5907. */
  5908. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5909. }
  5910. /**
  5911. * Class representing spherical polynomial coefficients to the 3rd degree
  5912. */
  5913. export class SphericalPolynomial {
  5914. private _harmonics;
  5915. /**
  5916. * The spherical harmonics used to create the polynomials.
  5917. */
  5918. readonly preScaledHarmonics: SphericalHarmonics;
  5919. /**
  5920. * The x coefficients of the spherical polynomial
  5921. */
  5922. x: Vector3;
  5923. /**
  5924. * The y coefficients of the spherical polynomial
  5925. */
  5926. y: Vector3;
  5927. /**
  5928. * The z coefficients of the spherical polynomial
  5929. */
  5930. z: Vector3;
  5931. /**
  5932. * The xx coefficients of the spherical polynomial
  5933. */
  5934. xx: Vector3;
  5935. /**
  5936. * The yy coefficients of the spherical polynomial
  5937. */
  5938. yy: Vector3;
  5939. /**
  5940. * The zz coefficients of the spherical polynomial
  5941. */
  5942. zz: Vector3;
  5943. /**
  5944. * The xy coefficients of the spherical polynomial
  5945. */
  5946. xy: Vector3;
  5947. /**
  5948. * The yz coefficients of the spherical polynomial
  5949. */
  5950. yz: Vector3;
  5951. /**
  5952. * The zx coefficients of the spherical polynomial
  5953. */
  5954. zx: Vector3;
  5955. /**
  5956. * Adds an ambient color to the spherical polynomial
  5957. * @param color the color to add
  5958. */
  5959. addAmbient(color: Color3): void;
  5960. /**
  5961. * Scales the spherical polynomial by the given amount
  5962. * @param scale the amount to scale
  5963. */
  5964. scaleInPlace(scale: number): void;
  5965. /**
  5966. * Gets the spherical polynomial from harmonics
  5967. * @param harmonics the spherical harmonics
  5968. * @returns the spherical polynomial
  5969. */
  5970. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5971. /**
  5972. * Constructs a spherical polynomial from an array.
  5973. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5974. * @returns the spherical polynomial
  5975. */
  5976. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5977. }
  5978. }
  5979. declare module BABYLON {
  5980. /**
  5981. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5982. */
  5983. export interface CubeMapInfo {
  5984. /**
  5985. * The pixel array for the front face.
  5986. * This is stored in format, left to right, up to down format.
  5987. */
  5988. front: Nullable<ArrayBufferView>;
  5989. /**
  5990. * The pixel array for the back face.
  5991. * This is stored in format, left to right, up to down format.
  5992. */
  5993. back: Nullable<ArrayBufferView>;
  5994. /**
  5995. * The pixel array for the left face.
  5996. * This is stored in format, left to right, up to down format.
  5997. */
  5998. left: Nullable<ArrayBufferView>;
  5999. /**
  6000. * The pixel array for the right face.
  6001. * This is stored in format, left to right, up to down format.
  6002. */
  6003. right: Nullable<ArrayBufferView>;
  6004. /**
  6005. * The pixel array for the up face.
  6006. * This is stored in format, left to right, up to down format.
  6007. */
  6008. up: Nullable<ArrayBufferView>;
  6009. /**
  6010. * The pixel array for the down face.
  6011. * This is stored in format, left to right, up to down format.
  6012. */
  6013. down: Nullable<ArrayBufferView>;
  6014. /**
  6015. * The size of the cubemap stored.
  6016. *
  6017. * Each faces will be size * size pixels.
  6018. */
  6019. size: number;
  6020. /**
  6021. * The format of the texture.
  6022. *
  6023. * RGBA, RGB.
  6024. */
  6025. format: number;
  6026. /**
  6027. * The type of the texture data.
  6028. *
  6029. * UNSIGNED_INT, FLOAT.
  6030. */
  6031. type: number;
  6032. /**
  6033. * Specifies whether the texture is in gamma space.
  6034. */
  6035. gammaSpace: boolean;
  6036. }
  6037. /**
  6038. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6039. */
  6040. export class PanoramaToCubeMapTools {
  6041. private static FACE_FRONT;
  6042. private static FACE_BACK;
  6043. private static FACE_RIGHT;
  6044. private static FACE_LEFT;
  6045. private static FACE_DOWN;
  6046. private static FACE_UP;
  6047. /**
  6048. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6049. *
  6050. * @param float32Array The source data.
  6051. * @param inputWidth The width of the input panorama.
  6052. * @param inputHeight The height of the input panorama.
  6053. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6054. * @return The cubemap data
  6055. */
  6056. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6057. private static CreateCubemapTexture;
  6058. private static CalcProjectionSpherical;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. /**
  6063. * Helper class dealing with the extraction of spherical polynomial dataArray
  6064. * from a cube map.
  6065. */
  6066. export class CubeMapToSphericalPolynomialTools {
  6067. private static FileFaces;
  6068. /**
  6069. * Converts a texture to the according Spherical Polynomial data.
  6070. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6071. *
  6072. * @param texture The texture to extract the information from.
  6073. * @return The Spherical Polynomial data.
  6074. */
  6075. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6076. /**
  6077. * Converts a cubemap to the according Spherical Polynomial data.
  6078. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6079. *
  6080. * @param cubeInfo The Cube map to extract the information from.
  6081. * @return The Spherical Polynomial data.
  6082. */
  6083. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6084. }
  6085. }
  6086. declare module BABYLON {
  6087. /**
  6088. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6089. * during the life time of the application.
  6090. */
  6091. export class EngineStore {
  6092. /** Gets the list of created engines */
  6093. static Instances: Engine[];
  6094. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  6095. /**
  6096. * Gets the latest created engine
  6097. */
  6098. static readonly LastCreatedEngine: Nullable<Engine>;
  6099. /**
  6100. * Gets the latest created scene
  6101. */
  6102. static readonly LastCreatedScene: Nullable<Scene>;
  6103. }
  6104. }
  6105. declare module BABYLON {
  6106. /**
  6107. * Define options used to create a render target texture
  6108. */
  6109. export class RenderTargetCreationOptions {
  6110. /**
  6111. * Specifies is mipmaps must be generated
  6112. */
  6113. generateMipMaps?: boolean;
  6114. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6115. generateDepthBuffer?: boolean;
  6116. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6117. generateStencilBuffer?: boolean;
  6118. /** Defines texture type (int by default) */
  6119. type?: number;
  6120. /** Defines sampling mode (trilinear by default) */
  6121. samplingMode?: number;
  6122. /** Defines format (RGBA by default) */
  6123. format?: number;
  6124. }
  6125. }
  6126. declare module BABYLON {
  6127. /**
  6128. * @hidden
  6129. **/
  6130. export class _AlphaState {
  6131. private _isAlphaBlendDirty;
  6132. private _isBlendFunctionParametersDirty;
  6133. private _isBlendEquationParametersDirty;
  6134. private _isBlendConstantsDirty;
  6135. private _alphaBlend;
  6136. private _blendFunctionParameters;
  6137. private _blendEquationParameters;
  6138. private _blendConstants;
  6139. /**
  6140. * Initializes the state.
  6141. */
  6142. constructor();
  6143. readonly isDirty: boolean;
  6144. alphaBlend: boolean;
  6145. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6146. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6147. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6148. reset(): void;
  6149. apply(gl: WebGLRenderingContext): void;
  6150. }
  6151. }
  6152. declare module BABYLON {
  6153. /**
  6154. * @hidden
  6155. **/
  6156. export class _DepthCullingState {
  6157. private _isDepthTestDirty;
  6158. private _isDepthMaskDirty;
  6159. private _isDepthFuncDirty;
  6160. private _isCullFaceDirty;
  6161. private _isCullDirty;
  6162. private _isZOffsetDirty;
  6163. private _isFrontFaceDirty;
  6164. private _depthTest;
  6165. private _depthMask;
  6166. private _depthFunc;
  6167. private _cull;
  6168. private _cullFace;
  6169. private _zOffset;
  6170. private _frontFace;
  6171. /**
  6172. * Initializes the state.
  6173. */
  6174. constructor();
  6175. readonly isDirty: boolean;
  6176. zOffset: number;
  6177. cullFace: Nullable<number>;
  6178. cull: Nullable<boolean>;
  6179. depthFunc: Nullable<number>;
  6180. depthMask: boolean;
  6181. depthTest: boolean;
  6182. frontFace: Nullable<number>;
  6183. reset(): void;
  6184. apply(gl: WebGLRenderingContext): void;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * @hidden
  6190. **/
  6191. export class _StencilState {
  6192. /** 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 */
  6193. static readonly ALWAYS: number;
  6194. /** Passed to stencilOperation to specify that stencil value must be kept */
  6195. static readonly KEEP: number;
  6196. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6197. static readonly REPLACE: number;
  6198. private _isStencilTestDirty;
  6199. private _isStencilMaskDirty;
  6200. private _isStencilFuncDirty;
  6201. private _isStencilOpDirty;
  6202. private _stencilTest;
  6203. private _stencilMask;
  6204. private _stencilFunc;
  6205. private _stencilFuncRef;
  6206. private _stencilFuncMask;
  6207. private _stencilOpStencilFail;
  6208. private _stencilOpDepthFail;
  6209. private _stencilOpStencilDepthPass;
  6210. readonly isDirty: boolean;
  6211. stencilFunc: number;
  6212. stencilFuncRef: number;
  6213. stencilFuncMask: number;
  6214. stencilOpStencilFail: number;
  6215. stencilOpDepthFail: number;
  6216. stencilOpStencilDepthPass: number;
  6217. stencilMask: number;
  6218. stencilTest: boolean;
  6219. constructor();
  6220. reset(): void;
  6221. apply(gl: WebGLRenderingContext): void;
  6222. }
  6223. }
  6224. declare module BABYLON {
  6225. /**
  6226. * @hidden
  6227. **/
  6228. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  6229. }
  6230. }
  6231. declare module BABYLON {
  6232. /**
  6233. * Class used to store data associated with WebGL texture data for the engine
  6234. * This class should not be used directly
  6235. */
  6236. export class InternalTexture {
  6237. /** hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6238. /**
  6239. * The source of the texture data is unknown
  6240. */
  6241. static DATASOURCE_UNKNOWN: number;
  6242. /**
  6243. * Texture data comes from an URL
  6244. */
  6245. static DATASOURCE_URL: number;
  6246. /**
  6247. * Texture data is only used for temporary storage
  6248. */
  6249. static DATASOURCE_TEMP: number;
  6250. /**
  6251. * Texture data comes from raw data (ArrayBuffer)
  6252. */
  6253. static DATASOURCE_RAW: number;
  6254. /**
  6255. * Texture content is dynamic (video or dynamic texture)
  6256. */
  6257. static DATASOURCE_DYNAMIC: number;
  6258. /**
  6259. * Texture content is generated by rendering to it
  6260. */
  6261. static DATASOURCE_RENDERTARGET: number;
  6262. /**
  6263. * Texture content is part of a multi render target process
  6264. */
  6265. static DATASOURCE_MULTIRENDERTARGET: number;
  6266. /**
  6267. * Texture data comes from a cube data file
  6268. */
  6269. static DATASOURCE_CUBE: number;
  6270. /**
  6271. * Texture data comes from a raw cube data
  6272. */
  6273. static DATASOURCE_CUBERAW: number;
  6274. /**
  6275. * Texture data come from a prefiltered cube data file
  6276. */
  6277. static DATASOURCE_CUBEPREFILTERED: number;
  6278. /**
  6279. * Texture content is raw 3D data
  6280. */
  6281. static DATASOURCE_RAW3D: number;
  6282. /**
  6283. * Texture content is a depth texture
  6284. */
  6285. static DATASOURCE_DEPTHTEXTURE: number;
  6286. /**
  6287. * Texture data comes from a raw cube data encoded with RGBD
  6288. */
  6289. static DATASOURCE_CUBERAW_RGBD: number;
  6290. /**
  6291. * Defines if the texture is ready
  6292. */
  6293. isReady: boolean;
  6294. /**
  6295. * Defines if the texture is a cube texture
  6296. */
  6297. isCube: boolean;
  6298. /**
  6299. * Defines if the texture contains 3D data
  6300. */
  6301. is3D: boolean;
  6302. /**
  6303. * Defines if the texture contains multiview data
  6304. */
  6305. isMultiview: boolean;
  6306. /**
  6307. * Gets the URL used to load this texture
  6308. */
  6309. url: string;
  6310. /**
  6311. * Gets the sampling mode of the texture
  6312. */
  6313. samplingMode: number;
  6314. /**
  6315. * Gets a boolean indicating if the texture needs mipmaps generation
  6316. */
  6317. generateMipMaps: boolean;
  6318. /**
  6319. * Gets the number of samples used by the texture (WebGL2+ only)
  6320. */
  6321. samples: number;
  6322. /**
  6323. * Gets the type of the texture (int, float...)
  6324. */
  6325. type: number;
  6326. /**
  6327. * Gets the format of the texture (RGB, RGBA...)
  6328. */
  6329. format: number;
  6330. /**
  6331. * Observable called when the texture is loaded
  6332. */
  6333. onLoadedObservable: Observable<InternalTexture>;
  6334. /**
  6335. * Gets the width of the texture
  6336. */
  6337. width: number;
  6338. /**
  6339. * Gets the height of the texture
  6340. */
  6341. height: number;
  6342. /**
  6343. * Gets the depth of the texture
  6344. */
  6345. depth: number;
  6346. /**
  6347. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6348. */
  6349. baseWidth: number;
  6350. /**
  6351. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6352. */
  6353. baseHeight: number;
  6354. /**
  6355. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6356. */
  6357. baseDepth: number;
  6358. /**
  6359. * Gets a boolean indicating if the texture is inverted on Y axis
  6360. */
  6361. invertY: boolean;
  6362. /** @hidden */ private _invertVScale: boolean;
  6363. /** @hidden */ private _associatedChannel: number;
  6364. /** @hidden */ private _dataSource: number;
  6365. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6366. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  6367. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  6368. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6369. /** @hidden */ private _size: number;
  6370. /** @hidden */ private _extension: string;
  6371. /** @hidden */ private _files: Nullable<string[]>;
  6372. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  6373. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  6374. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  6375. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6376. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6377. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6378. /** @hidden */ private _attachments: Nullable<number[]>;
  6379. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  6380. /** @hidden */ private _cachedWrapU: Nullable<number>;
  6381. /** @hidden */ private _cachedWrapV: Nullable<number>;
  6382. /** @hidden */ private _cachedWrapR: Nullable<number>;
  6383. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  6384. /** @hidden */ private _isDisabled: boolean;
  6385. /** @hidden */ private _compression: Nullable<string>;
  6386. /** @hidden */ private _generateStencilBuffer: boolean;
  6387. /** @hidden */ private _generateDepthBuffer: boolean;
  6388. /** @hidden */ private _comparisonFunction: number;
  6389. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6390. /** @hidden */ private _lodGenerationScale: number;
  6391. /** @hidden */ private _lodGenerationOffset: number;
  6392. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  6393. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  6394. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  6395. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  6396. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  6397. /** @hidden */ private _isRGBD: boolean;
  6398. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  6399. /** @hidden */ private _references: number;
  6400. private _engine;
  6401. /**
  6402. * Gets the Engine the texture belongs to.
  6403. * @returns The babylon engine
  6404. */
  6405. getEngine(): Engine;
  6406. /**
  6407. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6408. */
  6409. readonly dataSource: number;
  6410. /**
  6411. * Creates a new InternalTexture
  6412. * @param engine defines the engine to use
  6413. * @param dataSource defines the type of data that will be used
  6414. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6415. */
  6416. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6417. /**
  6418. * Increments the number of references (ie. the number of Texture that point to it)
  6419. */
  6420. incrementReferences(): void;
  6421. /**
  6422. * Change the size of the texture (not the size of the content)
  6423. * @param width defines the new width
  6424. * @param height defines the new height
  6425. * @param depth defines the new depth (1 by default)
  6426. */
  6427. updateSize(width: int, height: int, depth?: int): void;
  6428. /** @hidden */ private _rebuild(): void;
  6429. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  6430. /**
  6431. * Dispose the current allocated resources
  6432. */
  6433. dispose(): void;
  6434. }
  6435. }
  6436. declare module BABYLON {
  6437. /**
  6438. * This represents the main contract an easing function should follow.
  6439. * Easing functions are used throughout the animation system.
  6440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6441. */
  6442. export interface IEasingFunction {
  6443. /**
  6444. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6445. * of the easing function.
  6446. * The link below provides some of the most common examples of easing functions.
  6447. * @see https://easings.net/
  6448. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6449. * @returns the corresponding value on the curve defined by the easing function
  6450. */
  6451. ease(gradient: number): number;
  6452. }
  6453. /**
  6454. * Base class used for every default easing function.
  6455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6456. */
  6457. export class EasingFunction implements IEasingFunction {
  6458. /**
  6459. * Interpolation follows the mathematical formula associated with the easing function.
  6460. */
  6461. static readonly EASINGMODE_EASEIN: number;
  6462. /**
  6463. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6464. */
  6465. static readonly EASINGMODE_EASEOUT: number;
  6466. /**
  6467. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6468. */
  6469. static readonly EASINGMODE_EASEINOUT: number;
  6470. private _easingMode;
  6471. /**
  6472. * Sets the easing mode of the current function.
  6473. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6474. */
  6475. setEasingMode(easingMode: number): void;
  6476. /**
  6477. * Gets the current easing mode.
  6478. * @returns the easing mode
  6479. */
  6480. getEasingMode(): number;
  6481. /**
  6482. * @hidden
  6483. */
  6484. easeInCore(gradient: number): number;
  6485. /**
  6486. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6487. * of the easing function.
  6488. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6489. * @returns the corresponding value on the curve defined by the easing function
  6490. */
  6491. ease(gradient: number): number;
  6492. }
  6493. /**
  6494. * Easing function with a circle shape (see link below).
  6495. * @see https://easings.net/#easeInCirc
  6496. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6497. */
  6498. export class CircleEase extends EasingFunction implements IEasingFunction {
  6499. /** @hidden */
  6500. easeInCore(gradient: number): number;
  6501. }
  6502. /**
  6503. * Easing function with a ease back shape (see link below).
  6504. * @see https://easings.net/#easeInBack
  6505. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6506. */
  6507. export class BackEase extends EasingFunction implements IEasingFunction {
  6508. /** Defines the amplitude of the function */
  6509. amplitude: number;
  6510. /**
  6511. * Instantiates a back ease easing
  6512. * @see https://easings.net/#easeInBack
  6513. * @param amplitude Defines the amplitude of the function
  6514. */
  6515. constructor(
  6516. /** Defines the amplitude of the function */
  6517. amplitude?: number);
  6518. /** @hidden */
  6519. easeInCore(gradient: number): number;
  6520. }
  6521. /**
  6522. * Easing function with a bouncing shape (see link below).
  6523. * @see https://easings.net/#easeInBounce
  6524. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6525. */
  6526. export class BounceEase extends EasingFunction implements IEasingFunction {
  6527. /** Defines the number of bounces */
  6528. bounces: number;
  6529. /** Defines the amplitude of the bounce */
  6530. bounciness: number;
  6531. /**
  6532. * Instantiates a bounce easing
  6533. * @see https://easings.net/#easeInBounce
  6534. * @param bounces Defines the number of bounces
  6535. * @param bounciness Defines the amplitude of the bounce
  6536. */
  6537. constructor(
  6538. /** Defines the number of bounces */
  6539. bounces?: number,
  6540. /** Defines the amplitude of the bounce */
  6541. bounciness?: number);
  6542. /** @hidden */
  6543. easeInCore(gradient: number): number;
  6544. }
  6545. /**
  6546. * Easing function with a power of 3 shape (see link below).
  6547. * @see https://easings.net/#easeInCubic
  6548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6549. */
  6550. export class CubicEase extends EasingFunction implements IEasingFunction {
  6551. /** @hidden */
  6552. easeInCore(gradient: number): number;
  6553. }
  6554. /**
  6555. * Easing function with an elastic shape (see link below).
  6556. * @see https://easings.net/#easeInElastic
  6557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6558. */
  6559. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6560. /** Defines the number of oscillations*/
  6561. oscillations: number;
  6562. /** Defines the amplitude of the oscillations*/
  6563. springiness: number;
  6564. /**
  6565. * Instantiates an elastic easing function
  6566. * @see https://easings.net/#easeInElastic
  6567. * @param oscillations Defines the number of oscillations
  6568. * @param springiness Defines the amplitude of the oscillations
  6569. */
  6570. constructor(
  6571. /** Defines the number of oscillations*/
  6572. oscillations?: number,
  6573. /** Defines the amplitude of the oscillations*/
  6574. springiness?: number);
  6575. /** @hidden */
  6576. easeInCore(gradient: number): number;
  6577. }
  6578. /**
  6579. * Easing function with an exponential shape (see link below).
  6580. * @see https://easings.net/#easeInExpo
  6581. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6582. */
  6583. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6584. /** Defines the exponent of the function */
  6585. exponent: number;
  6586. /**
  6587. * Instantiates an exponential easing function
  6588. * @see https://easings.net/#easeInExpo
  6589. * @param exponent Defines the exponent of the function
  6590. */
  6591. constructor(
  6592. /** Defines the exponent of the function */
  6593. exponent?: number);
  6594. /** @hidden */
  6595. easeInCore(gradient: number): number;
  6596. }
  6597. /**
  6598. * Easing function with a power shape (see link below).
  6599. * @see https://easings.net/#easeInQuad
  6600. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6601. */
  6602. export class PowerEase extends EasingFunction implements IEasingFunction {
  6603. /** Defines the power of the function */
  6604. power: number;
  6605. /**
  6606. * Instantiates an power base easing function
  6607. * @see https://easings.net/#easeInQuad
  6608. * @param power Defines the power of the function
  6609. */
  6610. constructor(
  6611. /** Defines the power of the function */
  6612. power?: number);
  6613. /** @hidden */
  6614. easeInCore(gradient: number): number;
  6615. }
  6616. /**
  6617. * Easing function with a power of 2 shape (see link below).
  6618. * @see https://easings.net/#easeInQuad
  6619. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6620. */
  6621. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6622. /** @hidden */
  6623. easeInCore(gradient: number): number;
  6624. }
  6625. /**
  6626. * Easing function with a power of 4 shape (see link below).
  6627. * @see https://easings.net/#easeInQuart
  6628. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6629. */
  6630. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6631. /** @hidden */
  6632. easeInCore(gradient: number): number;
  6633. }
  6634. /**
  6635. * Easing function with a power of 5 shape (see link below).
  6636. * @see https://easings.net/#easeInQuint
  6637. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6638. */
  6639. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6640. /** @hidden */
  6641. easeInCore(gradient: number): number;
  6642. }
  6643. /**
  6644. * Easing function with a sin shape (see link below).
  6645. * @see https://easings.net/#easeInSine
  6646. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6647. */
  6648. export class SineEase extends EasingFunction implements IEasingFunction {
  6649. /** @hidden */
  6650. easeInCore(gradient: number): number;
  6651. }
  6652. /**
  6653. * Easing function with a bezier shape (see link below).
  6654. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6655. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6656. */
  6657. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6658. /** Defines the x component of the start tangent in the bezier curve */
  6659. x1: number;
  6660. /** Defines the y component of the start tangent in the bezier curve */
  6661. y1: number;
  6662. /** Defines the x component of the end tangent in the bezier curve */
  6663. x2: number;
  6664. /** Defines the y component of the end tangent in the bezier curve */
  6665. y2: number;
  6666. /**
  6667. * Instantiates a bezier function
  6668. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6669. * @param x1 Defines the x component of the start tangent in the bezier curve
  6670. * @param y1 Defines the y component of the start tangent in the bezier curve
  6671. * @param x2 Defines the x component of the end tangent in the bezier curve
  6672. * @param y2 Defines the y component of the end tangent in the bezier curve
  6673. */
  6674. constructor(
  6675. /** Defines the x component of the start tangent in the bezier curve */
  6676. x1?: number,
  6677. /** Defines the y component of the start tangent in the bezier curve */
  6678. y1?: number,
  6679. /** Defines the x component of the end tangent in the bezier curve */
  6680. x2?: number,
  6681. /** Defines the y component of the end tangent in the bezier curve */
  6682. y2?: number);
  6683. /** @hidden */
  6684. easeInCore(gradient: number): number;
  6685. }
  6686. }
  6687. declare module BABYLON {
  6688. /**
  6689. * Defines an interface which represents an animation key frame
  6690. */
  6691. export interface IAnimationKey {
  6692. /**
  6693. * Frame of the key frame
  6694. */
  6695. frame: number;
  6696. /**
  6697. * Value at the specifies key frame
  6698. */
  6699. value: any;
  6700. /**
  6701. * The input tangent for the cubic hermite spline
  6702. */
  6703. inTangent?: any;
  6704. /**
  6705. * The output tangent for the cubic hermite spline
  6706. */
  6707. outTangent?: any;
  6708. /**
  6709. * The animation interpolation type
  6710. */
  6711. interpolation?: AnimationKeyInterpolation;
  6712. }
  6713. /**
  6714. * Enum for the animation key frame interpolation type
  6715. */
  6716. export enum AnimationKeyInterpolation {
  6717. /**
  6718. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6719. */
  6720. STEP = 1
  6721. }
  6722. }
  6723. declare module BABYLON {
  6724. /**
  6725. * Represents the range of an animation
  6726. */
  6727. export class AnimationRange {
  6728. /**The name of the animation range**/
  6729. name: string;
  6730. /**The starting frame of the animation */
  6731. from: number;
  6732. /**The ending frame of the animation*/
  6733. to: number;
  6734. /**
  6735. * Initializes the range of an animation
  6736. * @param name The name of the animation range
  6737. * @param from The starting frame of the animation
  6738. * @param to The ending frame of the animation
  6739. */
  6740. constructor(
  6741. /**The name of the animation range**/
  6742. name: string,
  6743. /**The starting frame of the animation */
  6744. from: number,
  6745. /**The ending frame of the animation*/
  6746. to: number);
  6747. /**
  6748. * Makes a copy of the animation range
  6749. * @returns A copy of the animation range
  6750. */
  6751. clone(): AnimationRange;
  6752. }
  6753. }
  6754. declare module BABYLON {
  6755. /**
  6756. * Composed of a frame, and an action function
  6757. */
  6758. export class AnimationEvent {
  6759. /** The frame for which the event is triggered **/
  6760. frame: number;
  6761. /** The event to perform when triggered **/
  6762. action: (currentFrame: number) => void;
  6763. /** Specifies if the event should be triggered only once**/
  6764. onlyOnce?: boolean | undefined;
  6765. /**
  6766. * Specifies if the animation event is done
  6767. */
  6768. isDone: boolean;
  6769. /**
  6770. * Initializes the animation event
  6771. * @param frame The frame for which the event is triggered
  6772. * @param action The event to perform when triggered
  6773. * @param onlyOnce Specifies if the event should be triggered only once
  6774. */
  6775. constructor(
  6776. /** The frame for which the event is triggered **/
  6777. frame: number,
  6778. /** The event to perform when triggered **/
  6779. action: (currentFrame: number) => void,
  6780. /** Specifies if the event should be triggered only once**/
  6781. onlyOnce?: boolean | undefined);
  6782. /** @hidden */ private _clone(): AnimationEvent;
  6783. }
  6784. }
  6785. declare module BABYLON {
  6786. /**
  6787. * Interface used to define a behavior
  6788. */
  6789. export interface Behavior<T> {
  6790. /** gets or sets behavior's name */
  6791. name: string;
  6792. /**
  6793. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6794. */
  6795. init(): void;
  6796. /**
  6797. * Called when the behavior is attached to a target
  6798. * @param target defines the target where the behavior is attached to
  6799. */
  6800. attach(target: T): void;
  6801. /**
  6802. * Called when the behavior is detached from its target
  6803. */
  6804. detach(): void;
  6805. }
  6806. /**
  6807. * Interface implemented by classes supporting behaviors
  6808. */
  6809. export interface IBehaviorAware<T> {
  6810. /**
  6811. * Attach a behavior
  6812. * @param behavior defines the behavior to attach
  6813. * @returns the current host
  6814. */
  6815. addBehavior(behavior: Behavior<T>): T;
  6816. /**
  6817. * Remove a behavior from the current object
  6818. * @param behavior defines the behavior to detach
  6819. * @returns the current host
  6820. */
  6821. removeBehavior(behavior: Behavior<T>): T;
  6822. /**
  6823. * Gets a behavior using its name to search
  6824. * @param name defines the name to search
  6825. * @returns the behavior or null if not found
  6826. */
  6827. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6828. }
  6829. }
  6830. declare module BABYLON {
  6831. /**
  6832. * @hidden
  6833. */
  6834. export class IntersectionInfo {
  6835. bu: Nullable<number>;
  6836. bv: Nullable<number>;
  6837. distance: number;
  6838. faceId: number;
  6839. subMeshId: number;
  6840. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6841. }
  6842. }
  6843. declare module BABYLON {
  6844. /**
  6845. * Class used to store bounding sphere information
  6846. */
  6847. export class BoundingSphere {
  6848. /**
  6849. * Gets the center of the bounding sphere in local space
  6850. */
  6851. readonly center: Vector3;
  6852. /**
  6853. * Radius of the bounding sphere in local space
  6854. */
  6855. radius: number;
  6856. /**
  6857. * Gets the center of the bounding sphere in world space
  6858. */
  6859. readonly centerWorld: Vector3;
  6860. /**
  6861. * Radius of the bounding sphere in world space
  6862. */
  6863. radiusWorld: number;
  6864. /**
  6865. * Gets the minimum vector in local space
  6866. */
  6867. readonly minimum: Vector3;
  6868. /**
  6869. * Gets the maximum vector in local space
  6870. */
  6871. readonly maximum: Vector3;
  6872. private _worldMatrix;
  6873. private static readonly TmpVector3;
  6874. /**
  6875. * Creates a new bounding sphere
  6876. * @param min defines the minimum vector (in local space)
  6877. * @param max defines the maximum vector (in local space)
  6878. * @param worldMatrix defines the new world matrix
  6879. */
  6880. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6881. /**
  6882. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6883. * @param min defines the new minimum vector (in local space)
  6884. * @param max defines the new maximum vector (in local space)
  6885. * @param worldMatrix defines the new world matrix
  6886. */
  6887. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6888. /**
  6889. * Scale the current bounding sphere by applying a scale factor
  6890. * @param factor defines the scale factor to apply
  6891. * @returns the current bounding box
  6892. */
  6893. scale(factor: number): BoundingSphere;
  6894. /**
  6895. * Gets the world matrix of the bounding box
  6896. * @returns a matrix
  6897. */
  6898. getWorldMatrix(): DeepImmutable<Matrix>;
  6899. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6900. /**
  6901. * Tests if the bounding sphere is intersecting the frustum planes
  6902. * @param frustumPlanes defines the frustum planes to test
  6903. * @returns true if there is an intersection
  6904. */
  6905. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6906. /**
  6907. * Tests if the bounding sphere center is in between the frustum planes.
  6908. * Used for optimistic fast inclusion.
  6909. * @param frustumPlanes defines the frustum planes to test
  6910. * @returns true if the sphere center is in between the frustum planes
  6911. */
  6912. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6913. /**
  6914. * Tests if a point is inside the bounding sphere
  6915. * @param point defines the point to test
  6916. * @returns true if the point is inside the bounding sphere
  6917. */
  6918. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6919. /**
  6920. * Checks if two sphere intersct
  6921. * @param sphere0 sphere 0
  6922. * @param sphere1 sphere 1
  6923. * @returns true if the speres intersect
  6924. */
  6925. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6926. }
  6927. }
  6928. declare module BABYLON {
  6929. /**
  6930. * Class used to store bounding box information
  6931. */
  6932. export class BoundingBox implements ICullable {
  6933. /**
  6934. * Gets the 8 vectors representing the bounding box in local space
  6935. */
  6936. readonly vectors: Vector3[];
  6937. /**
  6938. * Gets the center of the bounding box in local space
  6939. */
  6940. readonly center: Vector3;
  6941. /**
  6942. * Gets the center of the bounding box in world space
  6943. */
  6944. readonly centerWorld: Vector3;
  6945. /**
  6946. * Gets the extend size in local space
  6947. */
  6948. readonly extendSize: Vector3;
  6949. /**
  6950. * Gets the extend size in world space
  6951. */
  6952. readonly extendSizeWorld: Vector3;
  6953. /**
  6954. * Gets the OBB (object bounding box) directions
  6955. */
  6956. readonly directions: Vector3[];
  6957. /**
  6958. * Gets the 8 vectors representing the bounding box in world space
  6959. */
  6960. readonly vectorsWorld: Vector3[];
  6961. /**
  6962. * Gets the minimum vector in world space
  6963. */
  6964. readonly minimumWorld: Vector3;
  6965. /**
  6966. * Gets the maximum vector in world space
  6967. */
  6968. readonly maximumWorld: Vector3;
  6969. /**
  6970. * Gets the minimum vector in local space
  6971. */
  6972. readonly minimum: Vector3;
  6973. /**
  6974. * Gets the maximum vector in local space
  6975. */
  6976. readonly maximum: Vector3;
  6977. private _worldMatrix;
  6978. private static readonly TmpVector3;
  6979. /**
  6980. * @hidden
  6981. */ private _tag: number;
  6982. /**
  6983. * Creates a new bounding box
  6984. * @param min defines the minimum vector (in local space)
  6985. * @param max defines the maximum vector (in local space)
  6986. * @param worldMatrix defines the new world matrix
  6987. */
  6988. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6989. /**
  6990. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6991. * @param min defines the new minimum vector (in local space)
  6992. * @param max defines the new maximum vector (in local space)
  6993. * @param worldMatrix defines the new world matrix
  6994. */
  6995. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6996. /**
  6997. * Scale the current bounding box by applying a scale factor
  6998. * @param factor defines the scale factor to apply
  6999. * @returns the current bounding box
  7000. */
  7001. scale(factor: number): BoundingBox;
  7002. /**
  7003. * Gets the world matrix of the bounding box
  7004. * @returns a matrix
  7005. */
  7006. getWorldMatrix(): DeepImmutable<Matrix>;
  7007. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  7008. /**
  7009. * Tests if the bounding box is intersecting the frustum planes
  7010. * @param frustumPlanes defines the frustum planes to test
  7011. * @returns true if there is an intersection
  7012. */
  7013. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7014. /**
  7015. * Tests if the bounding box is entirely inside the frustum planes
  7016. * @param frustumPlanes defines the frustum planes to test
  7017. * @returns true if there is an inclusion
  7018. */
  7019. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7020. /**
  7021. * Tests if a point is inside the bounding box
  7022. * @param point defines the point to test
  7023. * @returns true if the point is inside the bounding box
  7024. */
  7025. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7026. /**
  7027. * Tests if the bounding box intersects with a bounding sphere
  7028. * @param sphere defines the sphere to test
  7029. * @returns true if there is an intersection
  7030. */
  7031. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7032. /**
  7033. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7034. * @param min defines the min vector to use
  7035. * @param max defines the max vector to use
  7036. * @returns true if there is an intersection
  7037. */
  7038. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7039. /**
  7040. * Tests if two bounding boxes are intersections
  7041. * @param box0 defines the first box to test
  7042. * @param box1 defines the second box to test
  7043. * @returns true if there is an intersection
  7044. */
  7045. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7046. /**
  7047. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7048. * @param minPoint defines the minimum vector of the bounding box
  7049. * @param maxPoint defines the maximum vector of the bounding box
  7050. * @param sphereCenter defines the sphere center
  7051. * @param sphereRadius defines the sphere radius
  7052. * @returns true if there is an intersection
  7053. */
  7054. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7055. /**
  7056. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7057. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7058. * @param frustumPlanes defines the frustum planes to test
  7059. * @return true if there is an inclusion
  7060. */
  7061. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7062. /**
  7063. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7064. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7065. * @param frustumPlanes defines the frustum planes to test
  7066. * @return true if there is an intersection
  7067. */
  7068. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7069. }
  7070. }
  7071. declare module BABYLON {
  7072. /** @hidden */
  7073. export class Collider {
  7074. /** Define if a collision was found */
  7075. collisionFound: boolean;
  7076. /**
  7077. * Define last intersection point in local space
  7078. */
  7079. intersectionPoint: Vector3;
  7080. /**
  7081. * Define last collided mesh
  7082. */
  7083. collidedMesh: Nullable<AbstractMesh>;
  7084. private _collisionPoint;
  7085. private _planeIntersectionPoint;
  7086. private _tempVector;
  7087. private _tempVector2;
  7088. private _tempVector3;
  7089. private _tempVector4;
  7090. private _edge;
  7091. private _baseToVertex;
  7092. private _destinationPoint;
  7093. private _slidePlaneNormal;
  7094. private _displacementVector;
  7095. /** @hidden */ private _radius: Vector3;
  7096. /** @hidden */ private _retry: number;
  7097. private _velocity;
  7098. private _basePoint;
  7099. private _epsilon;
  7100. /** @hidden */ private _velocityWorldLength: number;
  7101. /** @hidden */ private _basePointWorld: Vector3;
  7102. private _velocityWorld;
  7103. private _normalizedVelocity;
  7104. /** @hidden */ private _initialVelocity: Vector3;
  7105. /** @hidden */ private _initialPosition: Vector3;
  7106. private _nearestDistance;
  7107. private _collisionMask;
  7108. collisionMask: number;
  7109. /**
  7110. * Gets the plane normal used to compute the sliding response (in local space)
  7111. */
  7112. readonly slidePlaneNormal: Vector3;
  7113. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7114. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7115. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7116. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7117. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7118. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7119. }
  7120. }
  7121. declare module BABYLON {
  7122. /**
  7123. * Interface for cullable objects
  7124. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7125. */
  7126. export interface ICullable {
  7127. /**
  7128. * Checks if the object or part of the object is in the frustum
  7129. * @param frustumPlanes Camera near/planes
  7130. * @returns true if the object is in frustum otherwise false
  7131. */
  7132. isInFrustum(frustumPlanes: Plane[]): boolean;
  7133. /**
  7134. * Checks if a cullable object (mesh...) is in the camera frustum
  7135. * Unlike isInFrustum this cheks the full bounding box
  7136. * @param frustumPlanes Camera near/planes
  7137. * @returns true if the object is in frustum otherwise false
  7138. */
  7139. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7140. }
  7141. /**
  7142. * Info for a bounding data of a mesh
  7143. */
  7144. export class BoundingInfo implements ICullable {
  7145. /**
  7146. * Bounding box for the mesh
  7147. */
  7148. readonly boundingBox: BoundingBox;
  7149. /**
  7150. * Bounding sphere for the mesh
  7151. */
  7152. readonly boundingSphere: BoundingSphere;
  7153. private _isLocked;
  7154. private static readonly TmpVector3;
  7155. /**
  7156. * Constructs bounding info
  7157. * @param minimum min vector of the bounding box/sphere
  7158. * @param maximum max vector of the bounding box/sphere
  7159. * @param worldMatrix defines the new world matrix
  7160. */
  7161. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7162. /**
  7163. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7164. * @param min defines the new minimum vector (in local space)
  7165. * @param max defines the new maximum vector (in local space)
  7166. * @param worldMatrix defines the new world matrix
  7167. */
  7168. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7169. /**
  7170. * min vector of the bounding box/sphere
  7171. */
  7172. readonly minimum: Vector3;
  7173. /**
  7174. * max vector of the bounding box/sphere
  7175. */
  7176. readonly maximum: Vector3;
  7177. /**
  7178. * If the info is locked and won't be updated to avoid perf overhead
  7179. */
  7180. isLocked: boolean;
  7181. /**
  7182. * Updates the bounding sphere and box
  7183. * @param world world matrix to be used to update
  7184. */
  7185. update(world: DeepImmutable<Matrix>): void;
  7186. /**
  7187. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7188. * @param center New center of the bounding info
  7189. * @param extend New extend of the bounding info
  7190. * @returns the current bounding info
  7191. */
  7192. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7193. /**
  7194. * Scale the current bounding info by applying a scale factor
  7195. * @param factor defines the scale factor to apply
  7196. * @returns the current bounding info
  7197. */
  7198. scale(factor: number): BoundingInfo;
  7199. /**
  7200. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7201. * @param frustumPlanes defines the frustum to test
  7202. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7203. * @returns true if the bounding info is in the frustum planes
  7204. */
  7205. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7206. /**
  7207. * Gets the world distance between the min and max points of the bounding box
  7208. */
  7209. readonly diagonalLength: number;
  7210. /**
  7211. * Checks if a cullable object (mesh...) is in the camera frustum
  7212. * Unlike isInFrustum this cheks the full bounding box
  7213. * @param frustumPlanes Camera near/planes
  7214. * @returns true if the object is in frustum otherwise false
  7215. */
  7216. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7217. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7218. /**
  7219. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7221. * @param point the point to check intersection with
  7222. * @returns if the point intersects
  7223. */
  7224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param boundingInfo the bounding info to check intersection with
  7229. * @param precise if the intersection should be done using OBB
  7230. * @returns if the bounding info intersects
  7231. */
  7232. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7233. }
  7234. }
  7235. declare module BABYLON {
  7236. /**
  7237. * Defines an array and its length.
  7238. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7239. */
  7240. export interface ISmartArrayLike<T> {
  7241. /**
  7242. * The data of the array.
  7243. */
  7244. data: Array<T>;
  7245. /**
  7246. * The active length of the array.
  7247. */
  7248. length: number;
  7249. }
  7250. /**
  7251. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7252. */
  7253. export class SmartArray<T> implements ISmartArrayLike<T> {
  7254. /**
  7255. * The full set of data from the array.
  7256. */
  7257. data: Array<T>;
  7258. /**
  7259. * The active length of the array.
  7260. */
  7261. length: number;
  7262. protected _id: number;
  7263. /**
  7264. * Instantiates a Smart Array.
  7265. * @param capacity defines the default capacity of the array.
  7266. */
  7267. constructor(capacity: number);
  7268. /**
  7269. * Pushes a value at the end of the active data.
  7270. * @param value defines the object to push in the array.
  7271. */
  7272. push(value: T): void;
  7273. /**
  7274. * Iterates over the active data and apply the lambda to them.
  7275. * @param func defines the action to apply on each value.
  7276. */
  7277. forEach(func: (content: T) => void): void;
  7278. /**
  7279. * Sorts the full sets of data.
  7280. * @param compareFn defines the comparison function to apply.
  7281. */
  7282. sort(compareFn: (a: T, b: T) => number): void;
  7283. /**
  7284. * Resets the active data to an empty array.
  7285. */
  7286. reset(): void;
  7287. /**
  7288. * Releases all the data from the array as well as the array.
  7289. */
  7290. dispose(): void;
  7291. /**
  7292. * Concats the active data with a given array.
  7293. * @param array defines the data to concatenate with.
  7294. */
  7295. concat(array: any): void;
  7296. /**
  7297. * Returns the position of a value in the active data.
  7298. * @param value defines the value to find the index for
  7299. * @returns the index if found in the active data otherwise -1
  7300. */
  7301. indexOf(value: T): number;
  7302. /**
  7303. * Returns whether an element is part of the active data.
  7304. * @param value defines the value to look for
  7305. * @returns true if found in the active data otherwise false
  7306. */
  7307. contains(value: T): boolean;
  7308. private static _GlobalId;
  7309. }
  7310. /**
  7311. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7312. * The data in this array can only be present once
  7313. */
  7314. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7315. private _duplicateId;
  7316. /**
  7317. * Pushes a value at the end of the active data.
  7318. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7319. * @param value defines the object to push in the array.
  7320. */
  7321. push(value: T): void;
  7322. /**
  7323. * Pushes a value at the end of the active data.
  7324. * If the data is already present, it won t be added again
  7325. * @param value defines the object to push in the array.
  7326. * @returns true if added false if it was already present
  7327. */
  7328. pushNoDuplicate(value: T): boolean;
  7329. /**
  7330. * Resets the active data to an empty array.
  7331. */
  7332. reset(): void;
  7333. /**
  7334. * Concats the active data with a given array.
  7335. * This ensures no dupplicate will be present in the result.
  7336. * @param array defines the data to concatenate with.
  7337. */
  7338. concatWithNoDuplicate(array: any): void;
  7339. }
  7340. }
  7341. declare module BABYLON {
  7342. /**
  7343. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7344. * separate meshes. This can be use to improve performances.
  7345. * @see http://doc.babylonjs.com/how_to/multi_materials
  7346. */
  7347. export class MultiMaterial extends Material {
  7348. private _subMaterials;
  7349. /**
  7350. * Gets or Sets the list of Materials used within the multi material.
  7351. * They need to be ordered according to the submeshes order in the associated mesh
  7352. */
  7353. subMaterials: Nullable<Material>[];
  7354. /**
  7355. * Function used to align with Node.getChildren()
  7356. * @returns the list of Materials used within the multi material
  7357. */
  7358. getChildren(): Nullable<Material>[];
  7359. /**
  7360. * Instantiates a new Multi Material
  7361. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7362. * separate meshes. This can be use to improve performances.
  7363. * @see http://doc.babylonjs.com/how_to/multi_materials
  7364. * @param name Define the name in the scene
  7365. * @param scene Define the scene the material belongs to
  7366. */
  7367. constructor(name: string, scene: Scene);
  7368. private _hookArray;
  7369. /**
  7370. * Get one of the submaterial by its index in the submaterials array
  7371. * @param index The index to look the sub material at
  7372. * @returns The Material if the index has been defined
  7373. */
  7374. getSubMaterial(index: number): Nullable<Material>;
  7375. /**
  7376. * Get the list of active textures for the whole sub materials list.
  7377. * @returns All the textures that will be used during the rendering
  7378. */
  7379. getActiveTextures(): BaseTexture[];
  7380. /**
  7381. * Gets the current class name of the material e.g. "MultiMaterial"
  7382. * Mainly use in serialization.
  7383. * @returns the class name
  7384. */
  7385. getClassName(): string;
  7386. /**
  7387. * Checks if the material is ready to render the requested sub mesh
  7388. * @param mesh Define the mesh the submesh belongs to
  7389. * @param subMesh Define the sub mesh to look readyness for
  7390. * @param useInstances Define whether or not the material is used with instances
  7391. * @returns true if ready, otherwise false
  7392. */
  7393. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7394. /**
  7395. * Clones the current material and its related sub materials
  7396. * @param name Define the name of the newly cloned material
  7397. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7398. * @returns the cloned material
  7399. */
  7400. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7401. /**
  7402. * Serializes the materials into a JSON representation.
  7403. * @returns the JSON representation
  7404. */
  7405. serialize(): any;
  7406. /**
  7407. * Dispose the material and release its associated resources
  7408. * @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)
  7409. * @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)
  7410. * @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)
  7411. */
  7412. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7413. /**
  7414. * Creates a MultiMaterial from parsed MultiMaterial data.
  7415. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7416. * @param scene defines the hosting scene
  7417. * @returns a new MultiMaterial
  7418. */
  7419. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7420. }
  7421. }
  7422. declare module BABYLON {
  7423. /**
  7424. * Class used to represent data loading progression
  7425. */
  7426. export class SceneLoaderFlags {
  7427. private static _ForceFullSceneLoadingForIncremental;
  7428. private static _ShowLoadingScreen;
  7429. private static _CleanBoneMatrixWeights;
  7430. private static _loggingLevel;
  7431. /**
  7432. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7433. */
  7434. static ForceFullSceneLoadingForIncremental: boolean;
  7435. /**
  7436. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7437. */
  7438. static ShowLoadingScreen: boolean;
  7439. /**
  7440. * Defines the current logging level (while loading the scene)
  7441. * @ignorenaming
  7442. */
  7443. static loggingLevel: number;
  7444. /**
  7445. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7446. */
  7447. static CleanBoneMatrixWeights: boolean;
  7448. }
  7449. }
  7450. declare module BABYLON {
  7451. /**
  7452. * 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.
  7453. * @see https://doc.babylonjs.com/how_to/transformnode
  7454. */
  7455. export class TransformNode extends Node {
  7456. /**
  7457. * Object will not rotate to face the camera
  7458. */
  7459. static BILLBOARDMODE_NONE: number;
  7460. /**
  7461. * Object will rotate to face the camera but only on the x axis
  7462. */
  7463. static BILLBOARDMODE_X: number;
  7464. /**
  7465. * Object will rotate to face the camera but only on the y axis
  7466. */
  7467. static BILLBOARDMODE_Y: number;
  7468. /**
  7469. * Object will rotate to face the camera but only on the z axis
  7470. */
  7471. static BILLBOARDMODE_Z: number;
  7472. /**
  7473. * Object will rotate to face the camera
  7474. */
  7475. static BILLBOARDMODE_ALL: number;
  7476. private _forward;
  7477. private _forwardInverted;
  7478. private _up;
  7479. private _right;
  7480. private _rightInverted;
  7481. private _position;
  7482. private _rotation;
  7483. private _rotationQuaternion;
  7484. protected _scaling: Vector3;
  7485. protected _isDirty: boolean;
  7486. private _transformToBoneReferal;
  7487. private _billboardMode;
  7488. /**
  7489. * Gets or sets the billboard mode. Default is 0.
  7490. *
  7491. * | Value | Type | Description |
  7492. * | --- | --- | --- |
  7493. * | 0 | BILLBOARDMODE_NONE | |
  7494. * | 1 | BILLBOARDMODE_X | |
  7495. * | 2 | BILLBOARDMODE_Y | |
  7496. * | 4 | BILLBOARDMODE_Z | |
  7497. * | 7 | BILLBOARDMODE_ALL | |
  7498. *
  7499. */
  7500. billboardMode: number;
  7501. private _preserveParentRotationForBillboard;
  7502. /**
  7503. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7504. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7505. */
  7506. preserveParentRotationForBillboard: boolean;
  7507. /**
  7508. * 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
  7509. */
  7510. scalingDeterminant: number;
  7511. private _infiniteDistance;
  7512. /**
  7513. * Gets or sets the distance of the object to max, often used by skybox
  7514. */
  7515. infiniteDistance: boolean;
  7516. /**
  7517. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7518. * By default the system will update normals to compensate
  7519. */
  7520. ignoreNonUniformScaling: boolean;
  7521. /**
  7522. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7523. */
  7524. reIntegrateRotationIntoRotationQuaternion: boolean;
  7525. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  7526. /** @hidden */ private _localMatrix: Matrix;
  7527. private _usePivotMatrix;
  7528. private _absolutePosition;
  7529. private _pivotMatrix;
  7530. private _pivotMatrixInverse;
  7531. protected _postMultiplyPivotMatrix: boolean;
  7532. protected _isWorldMatrixFrozen: boolean;
  7533. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  7534. /**
  7535. * An event triggered after the world matrix is updated
  7536. */
  7537. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7538. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7539. /**
  7540. * Gets a string identifying the name of the class
  7541. * @returns "TransformNode" string
  7542. */
  7543. getClassName(): string;
  7544. /**
  7545. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7546. */
  7547. position: Vector3;
  7548. /**
  7549. * 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)).
  7550. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7551. */
  7552. rotation: Vector3;
  7553. /**
  7554. * 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)).
  7555. */
  7556. scaling: Vector3;
  7557. /**
  7558. * 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).
  7559. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7560. */
  7561. rotationQuaternion: Nullable<Quaternion>;
  7562. /**
  7563. * The forward direction of that transform in world space.
  7564. */
  7565. readonly forward: Vector3;
  7566. /**
  7567. * The up direction of that transform in world space.
  7568. */
  7569. readonly up: Vector3;
  7570. /**
  7571. * The right direction of that transform in world space.
  7572. */
  7573. readonly right: Vector3;
  7574. /**
  7575. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7576. * @param matrix the matrix to copy the pose from
  7577. * @returns this TransformNode.
  7578. */
  7579. updatePoseMatrix(matrix: Matrix): TransformNode;
  7580. /**
  7581. * Returns the mesh Pose matrix.
  7582. * @returns the pose matrix
  7583. */
  7584. getPoseMatrix(): Matrix;
  7585. /** @hidden */ private _isSynchronized(): boolean;
  7586. /** @hidden */ private _initCache(): void;
  7587. /**
  7588. * Flag the transform node as dirty (Forcing it to update everything)
  7589. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7590. * @returns this transform node
  7591. */
  7592. markAsDirty(property: string): TransformNode;
  7593. /**
  7594. * Returns the current mesh absolute position.
  7595. * Returns a Vector3.
  7596. */
  7597. readonly absolutePosition: Vector3;
  7598. /**
  7599. * Sets a new matrix to apply before all other transformation
  7600. * @param matrix defines the transform matrix
  7601. * @returns the current TransformNode
  7602. */
  7603. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7604. /**
  7605. * Sets a new pivot matrix to the current node
  7606. * @param matrix defines the new pivot matrix to use
  7607. * @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
  7608. * @returns the current TransformNode
  7609. */
  7610. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7611. /**
  7612. * Returns the mesh pivot matrix.
  7613. * Default : Identity.
  7614. * @returns the matrix
  7615. */
  7616. getPivotMatrix(): Matrix;
  7617. /**
  7618. * Prevents the World matrix to be computed any longer.
  7619. * @returns the TransformNode.
  7620. */
  7621. freezeWorldMatrix(): TransformNode;
  7622. /**
  7623. * Allows back the World matrix computation.
  7624. * @returns the TransformNode.
  7625. */
  7626. unfreezeWorldMatrix(): this;
  7627. /**
  7628. * True if the World matrix has been frozen.
  7629. */
  7630. readonly isWorldMatrixFrozen: boolean;
  7631. /**
  7632. * Retuns the mesh absolute position in the World.
  7633. * @returns a Vector3.
  7634. */
  7635. getAbsolutePosition(): Vector3;
  7636. /**
  7637. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7638. * @param absolutePosition the absolute position to set
  7639. * @returns the TransformNode.
  7640. */
  7641. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7642. /**
  7643. * Sets the mesh position in its local space.
  7644. * @param vector3 the position to set in localspace
  7645. * @returns the TransformNode.
  7646. */
  7647. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7648. /**
  7649. * Returns the mesh position in the local space from the current World matrix values.
  7650. * @returns a new Vector3.
  7651. */
  7652. getPositionExpressedInLocalSpace(): Vector3;
  7653. /**
  7654. * Translates the mesh along the passed Vector3 in its local space.
  7655. * @param vector3 the distance to translate in localspace
  7656. * @returns the TransformNode.
  7657. */
  7658. locallyTranslate(vector3: Vector3): TransformNode;
  7659. private static _lookAtVectorCache;
  7660. /**
  7661. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7662. * @param targetPoint the position (must be in same space as current mesh) to look at
  7663. * @param yawCor optional yaw (y-axis) correction in radians
  7664. * @param pitchCor optional pitch (x-axis) correction in radians
  7665. * @param rollCor optional roll (z-axis) correction in radians
  7666. * @param space the choosen space of the target
  7667. * @returns the TransformNode.
  7668. */
  7669. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7670. /**
  7671. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7672. * This Vector3 is expressed in the World space.
  7673. * @param localAxis axis to rotate
  7674. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7675. */
  7676. getDirection(localAxis: Vector3): Vector3;
  7677. /**
  7678. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7679. * localAxis is expressed in the mesh local space.
  7680. * result is computed in the Wordl space from the mesh World matrix.
  7681. * @param localAxis axis to rotate
  7682. * @param result the resulting transformnode
  7683. * @returns this TransformNode.
  7684. */
  7685. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7686. /**
  7687. * Sets this transform node rotation to the given local axis.
  7688. * @param localAxis the axis in local space
  7689. * @param yawCor optional yaw (y-axis) correction in radians
  7690. * @param pitchCor optional pitch (x-axis) correction in radians
  7691. * @param rollCor optional roll (z-axis) correction in radians
  7692. * @returns this TransformNode
  7693. */
  7694. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7695. /**
  7696. * Sets a new pivot point to the current node
  7697. * @param point defines the new pivot point to use
  7698. * @param space defines if the point is in world or local space (local by default)
  7699. * @returns the current TransformNode
  7700. */
  7701. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7702. /**
  7703. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7704. * @returns the pivot point
  7705. */
  7706. getPivotPoint(): Vector3;
  7707. /**
  7708. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7709. * @param result the vector3 to store the result
  7710. * @returns this TransformNode.
  7711. */
  7712. getPivotPointToRef(result: Vector3): TransformNode;
  7713. /**
  7714. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7715. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7716. */
  7717. getAbsolutePivotPoint(): Vector3;
  7718. /**
  7719. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7720. * @param result vector3 to store the result
  7721. * @returns this TransformNode.
  7722. */
  7723. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7724. /**
  7725. * Defines the passed node as the parent of the current node.
  7726. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7727. * @see https://doc.babylonjs.com/how_to/parenting
  7728. * @param node the node ot set as the parent
  7729. * @returns this TransformNode.
  7730. */
  7731. setParent(node: Nullable<Node>): TransformNode;
  7732. private _nonUniformScaling;
  7733. /**
  7734. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7735. */
  7736. readonly nonUniformScaling: boolean;
  7737. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  7738. /**
  7739. * Attach the current TransformNode to another TransformNode associated with a bone
  7740. * @param bone Bone affecting the TransformNode
  7741. * @param affectedTransformNode TransformNode associated with the bone
  7742. * @returns this object
  7743. */
  7744. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7745. /**
  7746. * Detach the transform node if its associated with a bone
  7747. * @returns this object
  7748. */
  7749. detachFromBone(): TransformNode;
  7750. private static _rotationAxisCache;
  7751. /**
  7752. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7753. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7754. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7755. * The passed axis is also normalized.
  7756. * @param axis the axis to rotate around
  7757. * @param amount the amount to rotate in radians
  7758. * @param space Space to rotate in (Default: local)
  7759. * @returns the TransformNode.
  7760. */
  7761. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7762. /**
  7763. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7764. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7765. * The passed axis is also normalized. .
  7766. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7767. * @param point the point to rotate around
  7768. * @param axis the axis to rotate around
  7769. * @param amount the amount to rotate in radians
  7770. * @returns the TransformNode
  7771. */
  7772. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7773. /**
  7774. * Translates the mesh along the axis vector for the passed distance in the given space.
  7775. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7776. * @param axis the axis to translate in
  7777. * @param distance the distance to translate
  7778. * @param space Space to rotate in (Default: local)
  7779. * @returns the TransformNode.
  7780. */
  7781. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7782. /**
  7783. * Adds a rotation step to the mesh current rotation.
  7784. * x, y, z are Euler angles expressed in radians.
  7785. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7786. * This means this rotation is made in the mesh local space only.
  7787. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7788. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7789. * ```javascript
  7790. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7791. * ```
  7792. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7793. * 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.
  7794. * @param x Rotation to add
  7795. * @param y Rotation to add
  7796. * @param z Rotation to add
  7797. * @returns the TransformNode.
  7798. */
  7799. addRotation(x: number, y: number, z: number): TransformNode;
  7800. /**
  7801. * @hidden
  7802. */
  7803. protected _getEffectiveParent(): Nullable<Node>;
  7804. /**
  7805. * Computes the world matrix of the node
  7806. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7807. * @returns the world matrix
  7808. */
  7809. computeWorldMatrix(force?: boolean): Matrix;
  7810. protected _afterComputeWorldMatrix(): void;
  7811. /**
  7812. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7813. * @param func callback function to add
  7814. *
  7815. * @returns the TransformNode.
  7816. */
  7817. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7818. /**
  7819. * Removes a registered callback function.
  7820. * @param func callback function to remove
  7821. * @returns the TransformNode.
  7822. */
  7823. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7824. /**
  7825. * Gets the position of the current mesh in camera space
  7826. * @param camera defines the camera to use
  7827. * @returns a position
  7828. */
  7829. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7830. /**
  7831. * Returns the distance from the mesh to the active camera
  7832. * @param camera defines the camera to use
  7833. * @returns the distance
  7834. */
  7835. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7836. /**
  7837. * Clone the current transform node
  7838. * @param name Name of the new clone
  7839. * @param newParent New parent for the clone
  7840. * @param doNotCloneChildren Do not clone children hierarchy
  7841. * @returns the new transform node
  7842. */
  7843. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7844. /**
  7845. * Serializes the objects information.
  7846. * @param currentSerializationObject defines the object to serialize in
  7847. * @returns the serialized object
  7848. */
  7849. serialize(currentSerializationObject?: any): any;
  7850. /**
  7851. * Returns a new TransformNode object parsed from the source provided.
  7852. * @param parsedTransformNode is the source.
  7853. * @param scene the scne the object belongs to
  7854. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7855. * @returns a new TransformNode object parsed from the source provided.
  7856. */
  7857. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7858. /**
  7859. * Get all child-transformNodes of this node
  7860. * @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
  7861. * @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
  7862. * @returns an array of TransformNode
  7863. */
  7864. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7865. /**
  7866. * Releases resources associated with this transform node.
  7867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7869. */
  7870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7871. }
  7872. }
  7873. declare module BABYLON {
  7874. /**
  7875. * Class used to override all child animations of a given target
  7876. */
  7877. export class AnimationPropertiesOverride {
  7878. /**
  7879. * Gets or sets a value indicating if animation blending must be used
  7880. */
  7881. enableBlending: boolean;
  7882. /**
  7883. * Gets or sets the blending speed to use when enableBlending is true
  7884. */
  7885. blendingSpeed: number;
  7886. /**
  7887. * Gets or sets the default loop mode to use
  7888. */
  7889. loopMode: number;
  7890. }
  7891. }
  7892. declare module BABYLON {
  7893. /**
  7894. * Class used to store bone information
  7895. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7896. */
  7897. export class Bone extends Node {
  7898. /**
  7899. * defines the bone name
  7900. */
  7901. name: string;
  7902. private static _tmpVecs;
  7903. private static _tmpQuat;
  7904. private static _tmpMats;
  7905. /**
  7906. * Gets the list of child bones
  7907. */
  7908. children: Bone[];
  7909. /** Gets the animations associated with this bone */
  7910. animations: Animation[];
  7911. /**
  7912. * Gets or sets bone length
  7913. */
  7914. length: number;
  7915. /**
  7916. * @hidden Internal only
  7917. * Set this value to map this bone to a different index in the transform matrices
  7918. * Set this value to -1 to exclude the bone from the transform matrices
  7919. */ private _index: Nullable<number>;
  7920. private _skeleton;
  7921. private _localMatrix;
  7922. private _restPose;
  7923. private _baseMatrix;
  7924. private _absoluteTransform;
  7925. private _invertedAbsoluteTransform;
  7926. private _parent;
  7927. private _scalingDeterminant;
  7928. private _worldTransform;
  7929. private _localScaling;
  7930. private _localRotation;
  7931. private _localPosition;
  7932. private _needToDecompose;
  7933. private _needToCompose;
  7934. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  7935. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  7936. /** @hidden */
  7937. /** @hidden */ private _matrix: Matrix;
  7938. /**
  7939. * Create a new bone
  7940. * @param name defines the bone name
  7941. * @param skeleton defines the parent skeleton
  7942. * @param parentBone defines the parent (can be null if the bone is the root)
  7943. * @param localMatrix defines the local matrix
  7944. * @param restPose defines the rest pose matrix
  7945. * @param baseMatrix defines the base matrix
  7946. * @param index defines index of the bone in the hiearchy
  7947. */
  7948. constructor(
  7949. /**
  7950. * defines the bone name
  7951. */
  7952. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  7953. /**
  7954. * Gets the current object class name.
  7955. * @return the class name
  7956. */
  7957. getClassName(): string;
  7958. /**
  7959. * Gets the parent skeleton
  7960. * @returns a skeleton
  7961. */
  7962. getSkeleton(): Skeleton;
  7963. /**
  7964. * Gets parent bone
  7965. * @returns a bone or null if the bone is the root of the bone hierarchy
  7966. */
  7967. getParent(): Nullable<Bone>;
  7968. /**
  7969. * Returns an array containing the root bones
  7970. * @returns an array containing the root bones
  7971. */
  7972. getChildren(): Array<Bone>;
  7973. /**
  7974. * Sets the parent bone
  7975. * @param parent defines the parent (can be null if the bone is the root)
  7976. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  7977. */
  7978. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  7979. /**
  7980. * Gets the local matrix
  7981. * @returns a matrix
  7982. */
  7983. getLocalMatrix(): Matrix;
  7984. /**
  7985. * Gets the base matrix (initial matrix which remains unchanged)
  7986. * @returns a matrix
  7987. */
  7988. getBaseMatrix(): Matrix;
  7989. /**
  7990. * Gets the rest pose matrix
  7991. * @returns a matrix
  7992. */
  7993. getRestPose(): Matrix;
  7994. /**
  7995. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  7996. */
  7997. getWorldMatrix(): Matrix;
  7998. /**
  7999. * Sets the local matrix to rest pose matrix
  8000. */
  8001. returnToRest(): void;
  8002. /**
  8003. * Gets the inverse of the absolute transform matrix.
  8004. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8005. * @returns a matrix
  8006. */
  8007. getInvertedAbsoluteTransform(): Matrix;
  8008. /**
  8009. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8010. * @returns a matrix
  8011. */
  8012. getAbsoluteTransform(): Matrix;
  8013. /**
  8014. * Links with the given transform node.
  8015. * The local matrix of this bone is copied from the transform node every frame.
  8016. * @param transformNode defines the transform node to link to
  8017. */
  8018. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8019. /** Gets or sets current position (in local space) */
  8020. position: Vector3;
  8021. /** Gets or sets current rotation (in local space) */
  8022. rotation: Vector3;
  8023. /** Gets or sets current rotation quaternion (in local space) */
  8024. rotationQuaternion: Quaternion;
  8025. /** Gets or sets current scaling (in local space) */
  8026. scaling: Vector3;
  8027. /**
  8028. * Gets the animation properties override
  8029. */
  8030. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8031. private _decompose;
  8032. private _compose;
  8033. /**
  8034. * Update the base and local matrices
  8035. * @param matrix defines the new base or local matrix
  8036. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8037. * @param updateLocalMatrix defines if the local matrix should be updated
  8038. */
  8039. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8040. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8041. /**
  8042. * Flag the bone as dirty (Forcing it to update everything)
  8043. */
  8044. markAsDirty(): void;
  8045. private _markAsDirtyAndCompose;
  8046. private _markAsDirtyAndDecompose;
  8047. /**
  8048. * Translate the bone in local or world space
  8049. * @param vec The amount to translate the bone
  8050. * @param space The space that the translation is in
  8051. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8052. */
  8053. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8054. /**
  8055. * Set the postion of the bone in local or world space
  8056. * @param position The position to set the bone
  8057. * @param space The space that the position is in
  8058. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8059. */
  8060. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8061. /**
  8062. * Set the absolute position of the bone (world space)
  8063. * @param position The position to set the bone
  8064. * @param mesh The mesh that this bone is attached to
  8065. */
  8066. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8067. /**
  8068. * Scale the bone on the x, y and z axes (in local space)
  8069. * @param x The amount to scale the bone on the x axis
  8070. * @param y The amount to scale the bone on the y axis
  8071. * @param z The amount to scale the bone on the z axis
  8072. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8073. */
  8074. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8075. /**
  8076. * Set the bone scaling in local space
  8077. * @param scale defines the scaling vector
  8078. */
  8079. setScale(scale: Vector3): void;
  8080. /**
  8081. * Gets the current scaling in local space
  8082. * @returns the current scaling vector
  8083. */
  8084. getScale(): Vector3;
  8085. /**
  8086. * Gets the current scaling in local space and stores it in a target vector
  8087. * @param result defines the target vector
  8088. */
  8089. getScaleToRef(result: Vector3): void;
  8090. /**
  8091. * Set the yaw, pitch, and roll of the bone in local or world space
  8092. * @param yaw The rotation of the bone on the y axis
  8093. * @param pitch The rotation of the bone on the x axis
  8094. * @param roll The rotation of the bone on the z axis
  8095. * @param space The space that the axes of rotation are in
  8096. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8097. */
  8098. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8099. /**
  8100. * Add a rotation to the bone on an axis in local or world space
  8101. * @param axis The axis to rotate the bone on
  8102. * @param amount The amount to rotate the bone
  8103. * @param space The space that the axis is in
  8104. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8105. */
  8106. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8107. /**
  8108. * Set the rotation of the bone to a particular axis angle in local or world space
  8109. * @param axis The axis to rotate the bone on
  8110. * @param angle The angle that the bone should be rotated to
  8111. * @param space The space that the axis is in
  8112. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8113. */
  8114. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8115. /**
  8116. * Set the euler rotation of the bone in local of world space
  8117. * @param rotation The euler rotation that the bone should be set to
  8118. * @param space The space that the rotation is in
  8119. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8120. */
  8121. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8122. /**
  8123. * Set the quaternion rotation of the bone in local of world space
  8124. * @param quat The quaternion rotation that the bone should be set to
  8125. * @param space The space that the rotation is in
  8126. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8127. */
  8128. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8129. /**
  8130. * Set the rotation matrix of the bone in local of world space
  8131. * @param rotMat The rotation matrix that the bone should be set to
  8132. * @param space The space that the rotation is in
  8133. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8134. */
  8135. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8136. private _rotateWithMatrix;
  8137. private _getNegativeRotationToRef;
  8138. /**
  8139. * Get the position of the bone in local or world space
  8140. * @param space The space that the returned position is in
  8141. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8142. * @returns The position of the bone
  8143. */
  8144. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8145. /**
  8146. * Copy the position of the bone to a vector3 in local or world space
  8147. * @param space The space that the returned position is in
  8148. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8149. * @param result The vector3 to copy the position to
  8150. */
  8151. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8152. /**
  8153. * Get the absolute position of the bone (world space)
  8154. * @param mesh The mesh that this bone is attached to
  8155. * @returns The absolute position of the bone
  8156. */
  8157. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8158. /**
  8159. * Copy the absolute position of the bone (world space) to the result param
  8160. * @param mesh The mesh that this bone is attached to
  8161. * @param result The vector3 to copy the absolute position to
  8162. */
  8163. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8164. /**
  8165. * Compute the absolute transforms of this bone and its children
  8166. */
  8167. computeAbsoluteTransforms(): void;
  8168. /**
  8169. * Get the world direction from an axis that is in the local space of the bone
  8170. * @param localAxis The local direction that is used to compute the world direction
  8171. * @param mesh The mesh that this bone is attached to
  8172. * @returns The world direction
  8173. */
  8174. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8175. /**
  8176. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8177. * @param localAxis The local direction that is used to compute the world direction
  8178. * @param mesh The mesh that this bone is attached to
  8179. * @param result The vector3 that the world direction will be copied to
  8180. */
  8181. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8182. /**
  8183. * Get the euler rotation of the bone in local or world space
  8184. * @param space The space that the rotation should be in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. * @returns The euler rotation
  8187. */
  8188. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8189. /**
  8190. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8191. * @param space The space that the rotation should be in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. * @param result The vector3 that the rotation should be copied to
  8194. */
  8195. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8196. /**
  8197. * Get the quaternion rotation of the bone in either local or world space
  8198. * @param space The space that the rotation should be in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. * @returns The quaternion rotation
  8201. */
  8202. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8203. /**
  8204. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8205. * @param space The space that the rotation should be in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. * @param result The quaternion that the rotation should be copied to
  8208. */
  8209. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8210. /**
  8211. * Get the rotation matrix of the bone in local or world space
  8212. * @param space The space that the rotation should be in
  8213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8214. * @returns The rotation matrix
  8215. */
  8216. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8217. /**
  8218. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8219. * @param space The space that the rotation should be in
  8220. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8221. * @param result The quaternion that the rotation should be copied to
  8222. */
  8223. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8224. /**
  8225. * Get the world position of a point that is in the local space of the bone
  8226. * @param position The local position
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @returns The world position
  8229. */
  8230. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8231. /**
  8232. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8233. * @param position The local position
  8234. * @param mesh The mesh that this bone is attached to
  8235. * @param result The vector3 that the world position should be copied to
  8236. */
  8237. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8238. /**
  8239. * Get the local position of a point that is in world space
  8240. * @param position The world position
  8241. * @param mesh The mesh that this bone is attached to
  8242. * @returns The local position
  8243. */
  8244. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8245. /**
  8246. * Get the local position of a point that is in world space and copy it to the result param
  8247. * @param position The world position
  8248. * @param mesh The mesh that this bone is attached to
  8249. * @param result The vector3 that the local position should be copied to
  8250. */
  8251. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8252. }
  8253. }
  8254. declare module BABYLON {
  8255. /**
  8256. * Enum that determines the text-wrapping mode to use.
  8257. */
  8258. export enum InspectableType {
  8259. /**
  8260. * Checkbox for booleans
  8261. */
  8262. Checkbox = 0,
  8263. /**
  8264. * Sliders for numbers
  8265. */
  8266. Slider = 1,
  8267. /**
  8268. * Vector3
  8269. */
  8270. Vector3 = 2,
  8271. /**
  8272. * Quaternions
  8273. */
  8274. Quaternion = 3,
  8275. /**
  8276. * Color3
  8277. */
  8278. Color3 = 4
  8279. }
  8280. /**
  8281. * Interface used to define custom inspectable properties.
  8282. * This interface is used by the inspector to display custom property grids
  8283. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8284. */
  8285. export interface IInspectable {
  8286. /**
  8287. * Gets the label to display
  8288. */
  8289. label: string;
  8290. /**
  8291. * Gets the name of the property to edit
  8292. */
  8293. propertyName: string;
  8294. /**
  8295. * Gets the type of the editor to use
  8296. */
  8297. type: InspectableType;
  8298. /**
  8299. * Gets the minimum value of the property when using in "slider" mode
  8300. */
  8301. min?: number;
  8302. /**
  8303. * Gets the maximum value of the property when using in "slider" mode
  8304. */
  8305. max?: number;
  8306. /**
  8307. * Gets the setp to use when using in "slider" mode
  8308. */
  8309. step?: number;
  8310. }
  8311. }
  8312. declare module BABYLON {
  8313. /**
  8314. * This represents the required contract to create a new type of texture loader.
  8315. */
  8316. export interface IInternalTextureLoader {
  8317. /**
  8318. * Defines wether the loader supports cascade loading the different faces.
  8319. */
  8320. supportCascades: boolean;
  8321. /**
  8322. * This returns if the loader support the current file information.
  8323. * @param extension defines the file extension of the file being loaded
  8324. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8325. * @param fallback defines the fallback internal texture if any
  8326. * @param isBase64 defines whether the texture is encoded as a base64
  8327. * @param isBuffer defines whether the texture data are stored as a buffer
  8328. * @returns true if the loader can load the specified file
  8329. */
  8330. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8331. /**
  8332. * Transform the url before loading if required.
  8333. * @param rootUrl the url of the texture
  8334. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8335. * @returns the transformed texture
  8336. */
  8337. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8338. /**
  8339. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8340. * @param rootUrl the url of the texture
  8341. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8342. * @returns the fallback texture
  8343. */
  8344. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8345. /**
  8346. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8347. * @param data contains the texture data
  8348. * @param texture defines the BabylonJS internal texture
  8349. * @param createPolynomials will be true if polynomials have been requested
  8350. * @param onLoad defines the callback to trigger once the texture is ready
  8351. * @param onError defines the callback to trigger in case of error
  8352. */
  8353. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8354. /**
  8355. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8356. * @param data contains the texture data
  8357. * @param texture defines the BabylonJS internal texture
  8358. * @param callback defines the method to call once ready to upload
  8359. */
  8360. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8361. }
  8362. }
  8363. declare module BABYLON {
  8364. interface Engine {
  8365. /**
  8366. * Creates a depth stencil cube texture.
  8367. * This is only available in WebGL 2.
  8368. * @param size The size of face edge in the cube texture.
  8369. * @param options The options defining the cube texture.
  8370. * @returns The cube texture
  8371. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8372. /**
  8373. * Creates a cube texture
  8374. * @param rootUrl defines the url where the files to load is located
  8375. * @param scene defines the current scene
  8376. * @param files defines the list of files to load (1 per face)
  8377. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8378. * @param onLoad defines an optional callback raised when the texture is loaded
  8379. * @param onError defines an optional callback raised if there is an issue to load the texture
  8380. * @param format defines the format of the data
  8381. * @param forcedExtension defines the extension to use to pick the right loader
  8382. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8383. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8384. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8385. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8386. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8387. * @returns the cube texture as an InternalTexture
  8388. */
  8389. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  8390. /**
  8391. * Creates a cube texture
  8392. * @param rootUrl defines the url where the files to load is located
  8393. * @param scene defines the current scene
  8394. * @param files defines the list of files to load (1 per face)
  8395. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8396. * @param onLoad defines an optional callback raised when the texture is loaded
  8397. * @param onError defines an optional callback raised if there is an issue to load the texture
  8398. * @param format defines the format of the data
  8399. * @param forcedExtension defines the extension to use to pick the right loader
  8400. * @returns the cube texture as an InternalTexture
  8401. */
  8402. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  8403. /**
  8404. * Creates a cube texture
  8405. * @param rootUrl defines the url where the files to load is located
  8406. * @param scene defines the current scene
  8407. * @param files defines the list of files to load (1 per face)
  8408. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8409. * @param onLoad defines an optional callback raised when the texture is loaded
  8410. * @param onError defines an optional callback raised if there is an issue to load the texture
  8411. * @param format defines the format of the data
  8412. * @param forcedExtension defines the extension to use to pick the right loader
  8413. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8414. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8415. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8416. * @returns the cube texture as an InternalTexture
  8417. */
  8418. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  8419. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8420. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8421. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8422. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8423. }
  8424. }
  8425. declare module BABYLON {
  8426. /**
  8427. * Class for creating a cube texture
  8428. */
  8429. export class CubeTexture extends BaseTexture {
  8430. private _delayedOnLoad;
  8431. /**
  8432. * The url of the texture
  8433. */
  8434. url: string;
  8435. /**
  8436. * Gets or sets the center of the bounding box associated with the cube texture.
  8437. * It must define where the camera used to render the texture was set
  8438. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8439. */
  8440. boundingBoxPosition: Vector3;
  8441. private _boundingBoxSize;
  8442. /**
  8443. * Gets or sets the size of the bounding box associated with the cube texture
  8444. * When defined, the cubemap will switch to local mode
  8445. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8446. * @example https://www.babylonjs-playground.com/#RNASML
  8447. */
  8448. /**
  8449. * Returns the bounding box size
  8450. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8451. */
  8452. boundingBoxSize: Vector3;
  8453. protected _rotationY: number;
  8454. /**
  8455. * Sets texture matrix rotation angle around Y axis in radians.
  8456. */
  8457. /**
  8458. * Gets texture matrix rotation angle around Y axis radians.
  8459. */
  8460. rotationY: number;
  8461. /**
  8462. * Are mip maps generated for this texture or not.
  8463. */
  8464. readonly noMipmap: boolean;
  8465. private _noMipmap;
  8466. private _files;
  8467. private _extensions;
  8468. private _textureMatrix;
  8469. private _format;
  8470. private _createPolynomials;
  8471. /** @hidden */ private _prefiltered: boolean;
  8472. /**
  8473. * Creates a cube texture from an array of image urls
  8474. * @param files defines an array of image urls
  8475. * @param scene defines the hosting scene
  8476. * @param noMipmap specifies if mip maps are not used
  8477. * @returns a cube texture
  8478. */
  8479. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8480. /**
  8481. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8482. * @param url defines the url of the prefiltered texture
  8483. * @param scene defines the scene the texture is attached to
  8484. * @param forcedExtension defines the extension of the file if different from the url
  8485. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8486. * @return the prefiltered texture
  8487. */
  8488. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8489. /**
  8490. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8491. * as prefiltered data.
  8492. * @param rootUrl defines the url of the texture or the root name of the six images
  8493. * @param scene defines the scene the texture is attached to
  8494. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8495. * @param noMipmap defines if mipmaps should be created or not
  8496. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8497. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8498. * @param onError defines a callback triggered in case of error during load
  8499. * @param format defines the internal format to use for the texture once loaded
  8500. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8501. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8502. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8503. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8504. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8505. * @return the cube texture
  8506. */
  8507. 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);
  8508. /**
  8509. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8510. */
  8511. readonly isPrefiltered: boolean;
  8512. /**
  8513. * Get the current class name of the texture useful for serialization or dynamic coding.
  8514. * @returns "CubeTexture"
  8515. */
  8516. getClassName(): string;
  8517. /**
  8518. * Update the url (and optional buffer) of this texture if url was null during construction.
  8519. * @param url the url of the texture
  8520. * @param forcedExtension defines the extension to use
  8521. * @param onLoad callback called when the texture is loaded (defaults to null)
  8522. */
  8523. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8524. /**
  8525. * Delays loading of the cube texture
  8526. * @param forcedExtension defines the extension to use
  8527. */
  8528. delayLoad(forcedExtension?: string): void;
  8529. /**
  8530. * Returns the reflection texture matrix
  8531. * @returns the reflection texture matrix
  8532. */
  8533. getReflectionTextureMatrix(): Matrix;
  8534. /**
  8535. * Sets the reflection texture matrix
  8536. * @param value Reflection texture matrix
  8537. */
  8538. setReflectionTextureMatrix(value: Matrix): void;
  8539. /**
  8540. * Parses text to create a cube texture
  8541. * @param parsedTexture define the serialized text to read from
  8542. * @param scene defines the hosting scene
  8543. * @param rootUrl defines the root url of the cube texture
  8544. * @returns a cube texture
  8545. */
  8546. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8547. /**
  8548. * Makes a clone, or deep copy, of the cube texture
  8549. * @returns a new cube texture
  8550. */
  8551. clone(): CubeTexture;
  8552. }
  8553. }
  8554. declare module BABYLON {
  8555. /** @hidden */
  8556. export var postprocessVertexShader: {
  8557. name: string;
  8558. shader: string;
  8559. };
  8560. }
  8561. declare module BABYLON {
  8562. /**
  8563. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8564. * This is the base of the follow, arc rotate cameras and Free camera
  8565. * @see http://doc.babylonjs.com/features/cameras
  8566. */
  8567. export class TargetCamera extends Camera {
  8568. private static _RigCamTransformMatrix;
  8569. private static _TargetTransformMatrix;
  8570. private static _TargetFocalPoint;
  8571. /**
  8572. * Define the current direction the camera is moving to
  8573. */
  8574. cameraDirection: Vector3;
  8575. /**
  8576. * Define the current rotation the camera is rotating to
  8577. */
  8578. cameraRotation: Vector2;
  8579. /**
  8580. * When set, the up vector of the camera will be updated by the rotation of the camera
  8581. */
  8582. updateUpVectorFromRotation: boolean;
  8583. private _tmpQuaternion;
  8584. /**
  8585. * Define the current rotation of the camera
  8586. */
  8587. rotation: Vector3;
  8588. /**
  8589. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8590. */
  8591. rotationQuaternion: Quaternion;
  8592. /**
  8593. * Define the current speed of the camera
  8594. */
  8595. speed: number;
  8596. /**
  8597. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8598. * around all axis.
  8599. */
  8600. noRotationConstraint: boolean;
  8601. /**
  8602. * Define the current target of the camera as an object or a position.
  8603. */
  8604. lockedTarget: any;
  8605. /** @hidden */ private _currentTarget: Vector3;
  8606. /** @hidden */ private _initialFocalDistance: number;
  8607. /** @hidden */ private _viewMatrix: Matrix;
  8608. /** @hidden */ private _camMatrix: Matrix;
  8609. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8610. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8611. /** @hidden */ private _referencePoint: Vector3;
  8612. /** @hidden */ private _transformedReferencePoint: Vector3;
  8613. protected _globalCurrentTarget: Vector3;
  8614. protected _globalCurrentUpVector: Vector3;
  8615. /** @hidden */ private _reset: () => void;
  8616. private _defaultUp;
  8617. /**
  8618. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8619. * This is the base of the follow, arc rotate cameras and Free camera
  8620. * @see http://doc.babylonjs.com/features/cameras
  8621. * @param name Defines the name of the camera in the scene
  8622. * @param position Defines the start position of the camera in the scene
  8623. * @param scene Defines the scene the camera belongs to
  8624. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8625. */
  8626. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8627. /**
  8628. * Gets the position in front of the camera at a given distance.
  8629. * @param distance The distance from the camera we want the position to be
  8630. * @returns the position
  8631. */
  8632. getFrontPosition(distance: number): Vector3;
  8633. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8634. private _storedPosition;
  8635. private _storedRotation;
  8636. private _storedRotationQuaternion;
  8637. /**
  8638. * Store current camera state of the camera (fov, position, rotation, etc..)
  8639. * @returns the camera
  8640. */
  8641. storeState(): Camera;
  8642. /**
  8643. * Restored camera state. You must call storeState() first
  8644. * @returns whether it was successful or not
  8645. * @hidden
  8646. */ private _restoreStateValues(): boolean;
  8647. /** @hidden */ private _initCache(): void;
  8648. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8649. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8650. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8651. /**
  8652. * Defines the target the camera should look at.
  8653. * This will automatically adapt alpha beta and radius to fit within the new target.
  8654. * @param target Defines the new target as a Vector or a mesh
  8655. */
  8656. setTarget(target: Vector3): void;
  8657. /**
  8658. * Return the current target position of the camera. This value is expressed in local space.
  8659. * @returns the target position
  8660. */
  8661. getTarget(): Vector3;
  8662. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8663. /** @hidden */ private _updatePosition(): void;
  8664. /** @hidden */ private _checkInputs(): void;
  8665. protected _updateCameraRotationMatrix(): void;
  8666. /**
  8667. * 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)
  8668. * @returns the current camera
  8669. */
  8670. private _rotateUpVectorWithCameraRotationMatrix;
  8671. private _cachedRotationZ;
  8672. private _cachedQuaternionRotationZ;
  8673. /** @hidden */ private _getViewMatrix(): Matrix;
  8674. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8675. /**
  8676. * @hidden
  8677. */
  8678. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8679. /**
  8680. * @hidden
  8681. */ private _updateRigCameras(): void;
  8682. private _getRigCamPositionAndTarget;
  8683. /**
  8684. * Gets the current object class name.
  8685. * @return the class name
  8686. */
  8687. getClassName(): string;
  8688. }
  8689. }
  8690. declare module BABYLON {
  8691. /**
  8692. * @ignore
  8693. * This is a list of all the different input types that are available in the application.
  8694. * Fo instance: ArcRotateCameraGamepadInput...
  8695. */
  8696. export var CameraInputTypes: {};
  8697. /**
  8698. * This is the contract to implement in order to create a new input class.
  8699. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8700. */
  8701. export interface ICameraInput<TCamera extends Camera> {
  8702. /**
  8703. * Defines the camera the input is attached to.
  8704. */
  8705. camera: Nullable<TCamera>;
  8706. /**
  8707. * Gets the class name of the current intput.
  8708. * @returns the class name
  8709. */
  8710. getClassName(): string;
  8711. /**
  8712. * Get the friendly name associated with the input class.
  8713. * @returns the input friendly name
  8714. */
  8715. getSimpleName(): string;
  8716. /**
  8717. * Attach the input controls to a specific dom element to get the input from.
  8718. * @param element Defines the element the controls should be listened from
  8719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8720. */
  8721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8722. /**
  8723. * Detach the current controls from the specified dom element.
  8724. * @param element Defines the element to stop listening the inputs from
  8725. */
  8726. detachControl(element: Nullable<HTMLElement>): void;
  8727. /**
  8728. * Update the current camera state depending on the inputs that have been used this frame.
  8729. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8730. */
  8731. checkInputs?: () => void;
  8732. }
  8733. /**
  8734. * Represents a map of input types to input instance or input index to input instance.
  8735. */
  8736. export interface CameraInputsMap<TCamera extends Camera> {
  8737. /**
  8738. * Accessor to the input by input type.
  8739. */
  8740. [name: string]: ICameraInput<TCamera>;
  8741. /**
  8742. * Accessor to the input by input index.
  8743. */
  8744. [idx: number]: ICameraInput<TCamera>;
  8745. }
  8746. /**
  8747. * This represents the input manager used within a camera.
  8748. * It helps dealing with all the different kind of input attached to a camera.
  8749. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8750. */
  8751. export class CameraInputsManager<TCamera extends Camera> {
  8752. /**
  8753. * Defines the list of inputs attahed to the camera.
  8754. */
  8755. attached: CameraInputsMap<TCamera>;
  8756. /**
  8757. * Defines the dom element the camera is collecting inputs from.
  8758. * This is null if the controls have not been attached.
  8759. */
  8760. attachedElement: Nullable<HTMLElement>;
  8761. /**
  8762. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8763. */
  8764. noPreventDefault: boolean;
  8765. /**
  8766. * Defined the camera the input manager belongs to.
  8767. */
  8768. camera: TCamera;
  8769. /**
  8770. * Update the current camera state depending on the inputs that have been used this frame.
  8771. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8772. */
  8773. checkInputs: () => void;
  8774. /**
  8775. * Instantiate a new Camera Input Manager.
  8776. * @param camera Defines the camera the input manager blongs to
  8777. */
  8778. constructor(camera: TCamera);
  8779. /**
  8780. * Add an input method to a camera
  8781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8782. * @param input camera input method
  8783. */
  8784. add(input: ICameraInput<TCamera>): void;
  8785. /**
  8786. * Remove a specific input method from a camera
  8787. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8788. * @param inputToRemove camera input method
  8789. */
  8790. remove(inputToRemove: ICameraInput<TCamera>): void;
  8791. /**
  8792. * Remove a specific input type from a camera
  8793. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8794. * @param inputType the type of the input to remove
  8795. */
  8796. removeByType(inputType: string): void;
  8797. private _addCheckInputs;
  8798. /**
  8799. * Attach the input controls to the currently attached dom element to listen the events from.
  8800. * @param input Defines the input to attach
  8801. */
  8802. attachInput(input: ICameraInput<TCamera>): void;
  8803. /**
  8804. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8805. * @param element Defines the dom element to collect the events from
  8806. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8807. */
  8808. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8809. /**
  8810. * Detach the current manager inputs controls from a specific dom element.
  8811. * @param element Defines the dom element to collect the events from
  8812. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8813. */
  8814. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8815. /**
  8816. * Rebuild the dynamic inputCheck function from the current list of
  8817. * defined inputs in the manager.
  8818. */
  8819. rebuildInputCheck(): void;
  8820. /**
  8821. * Remove all attached input methods from a camera
  8822. */
  8823. clear(): void;
  8824. /**
  8825. * Serialize the current input manager attached to a camera.
  8826. * This ensures than once parsed,
  8827. * the input associated to the camera will be identical to the current ones
  8828. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8829. */
  8830. serialize(serializedCamera: any): void;
  8831. /**
  8832. * Parses an input manager serialized JSON to restore the previous list of inputs
  8833. * and states associated to a camera.
  8834. * @param parsedCamera Defines the JSON to parse
  8835. */
  8836. parse(parsedCamera: any): void;
  8837. }
  8838. }
  8839. declare module BABYLON {
  8840. /**
  8841. * Gather the list of keyboard event types as constants.
  8842. */
  8843. export class KeyboardEventTypes {
  8844. /**
  8845. * The keydown event is fired when a key becomes active (pressed).
  8846. */
  8847. static readonly KEYDOWN: number;
  8848. /**
  8849. * The keyup event is fired when a key has been released.
  8850. */
  8851. static readonly KEYUP: number;
  8852. }
  8853. /**
  8854. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8855. */
  8856. export class KeyboardInfo {
  8857. /**
  8858. * Defines the type of event (KeyboardEventTypes)
  8859. */
  8860. type: number;
  8861. /**
  8862. * Defines the related dom event
  8863. */
  8864. event: KeyboardEvent;
  8865. /**
  8866. * Instantiates a new keyboard info.
  8867. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8868. * @param type Defines the type of event (KeyboardEventTypes)
  8869. * @param event Defines the related dom event
  8870. */
  8871. constructor(
  8872. /**
  8873. * Defines the type of event (KeyboardEventTypes)
  8874. */
  8875. type: number,
  8876. /**
  8877. * Defines the related dom event
  8878. */
  8879. event: KeyboardEvent);
  8880. }
  8881. /**
  8882. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8883. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8884. */
  8885. export class KeyboardInfoPre extends KeyboardInfo {
  8886. /**
  8887. * Defines the type of event (KeyboardEventTypes)
  8888. */
  8889. type: number;
  8890. /**
  8891. * Defines the related dom event
  8892. */
  8893. event: KeyboardEvent;
  8894. /**
  8895. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8896. */
  8897. skipOnPointerObservable: boolean;
  8898. /**
  8899. * Instantiates a new keyboard pre info.
  8900. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8901. * @param type Defines the type of event (KeyboardEventTypes)
  8902. * @param event Defines the related dom event
  8903. */
  8904. constructor(
  8905. /**
  8906. * Defines the type of event (KeyboardEventTypes)
  8907. */
  8908. type: number,
  8909. /**
  8910. * Defines the related dom event
  8911. */
  8912. event: KeyboardEvent);
  8913. }
  8914. }
  8915. declare module BABYLON {
  8916. /**
  8917. * Manage the keyboard inputs to control the movement of a free camera.
  8918. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8919. */
  8920. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8921. /**
  8922. * Defines the camera the input is attached to.
  8923. */
  8924. camera: FreeCamera;
  8925. /**
  8926. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8927. */
  8928. keysUp: number[];
  8929. /**
  8930. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8931. */
  8932. keysDown: number[];
  8933. /**
  8934. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8935. */
  8936. keysLeft: number[];
  8937. /**
  8938. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8939. */
  8940. keysRight: number[];
  8941. private _keys;
  8942. private _onCanvasBlurObserver;
  8943. private _onKeyboardObserver;
  8944. private _engine;
  8945. private _scene;
  8946. /**
  8947. * Attach the input controls to a specific dom element to get the input from.
  8948. * @param element Defines the element the controls should be listened from
  8949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8950. */
  8951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8952. /**
  8953. * Detach the current controls from the specified dom element.
  8954. * @param element Defines the element to stop listening the inputs from
  8955. */
  8956. detachControl(element: Nullable<HTMLElement>): void;
  8957. /**
  8958. * Update the current camera state depending on the inputs that have been used this frame.
  8959. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8960. */
  8961. checkInputs(): void;
  8962. /**
  8963. * Gets the class name of the current intput.
  8964. * @returns the class name
  8965. */
  8966. getClassName(): string;
  8967. /** @hidden */ private _onLostFocus(): void;
  8968. /**
  8969. * Get the friendly name associated with the input class.
  8970. * @returns the input friendly name
  8971. */
  8972. getSimpleName(): string;
  8973. }
  8974. }
  8975. declare module BABYLON {
  8976. /**
  8977. * Interface describing all the common properties and methods a shadow light needs to implement.
  8978. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8979. * as well as binding the different shadow properties to the effects.
  8980. */
  8981. export interface IShadowLight extends Light {
  8982. /**
  8983. * The light id in the scene (used in scene.findLighById for instance)
  8984. */
  8985. id: string;
  8986. /**
  8987. * The position the shdow will be casted from.
  8988. */
  8989. position: Vector3;
  8990. /**
  8991. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8992. */
  8993. direction: Vector3;
  8994. /**
  8995. * The transformed position. Position of the light in world space taking parenting in account.
  8996. */
  8997. transformedPosition: Vector3;
  8998. /**
  8999. * The transformed direction. Direction of the light in world space taking parenting in account.
  9000. */
  9001. transformedDirection: Vector3;
  9002. /**
  9003. * The friendly name of the light in the scene.
  9004. */
  9005. name: string;
  9006. /**
  9007. * Defines the shadow projection clipping minimum z value.
  9008. */
  9009. shadowMinZ: number;
  9010. /**
  9011. * Defines the shadow projection clipping maximum z value.
  9012. */
  9013. shadowMaxZ: number;
  9014. /**
  9015. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9016. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9017. */
  9018. computeTransformedInformation(): boolean;
  9019. /**
  9020. * Gets the scene the light belongs to.
  9021. * @returns The scene
  9022. */
  9023. getScene(): Scene;
  9024. /**
  9025. * Callback defining a custom Projection Matrix Builder.
  9026. * This can be used to override the default projection matrix computation.
  9027. */
  9028. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9029. /**
  9030. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9031. * @param matrix The materix to updated with the projection information
  9032. * @param viewMatrix The transform matrix of the light
  9033. * @param renderList The list of mesh to render in the map
  9034. * @returns The current light
  9035. */
  9036. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9037. /**
  9038. * Gets the current depth scale used in ESM.
  9039. * @returns The scale
  9040. */
  9041. getDepthScale(): number;
  9042. /**
  9043. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9044. * @returns true if a cube texture needs to be use
  9045. */
  9046. needCube(): boolean;
  9047. /**
  9048. * Detects if the projection matrix requires to be recomputed this frame.
  9049. * @returns true if it requires to be recomputed otherwise, false.
  9050. */
  9051. needProjectionMatrixCompute(): boolean;
  9052. /**
  9053. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9054. */
  9055. forceProjectionMatrixCompute(): void;
  9056. /**
  9057. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9058. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9059. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9060. */
  9061. getShadowDirection(faceIndex?: number): Vector3;
  9062. /**
  9063. * Gets the minZ used for shadow according to both the scene and the light.
  9064. * @param activeCamera The camera we are returning the min for
  9065. * @returns the depth min z
  9066. */
  9067. getDepthMinZ(activeCamera: Camera): number;
  9068. /**
  9069. * Gets the maxZ used for shadow according to both the scene and the light.
  9070. * @param activeCamera The camera we are returning the max for
  9071. * @returns the depth max z
  9072. */
  9073. getDepthMaxZ(activeCamera: Camera): number;
  9074. }
  9075. /**
  9076. * Base implementation IShadowLight
  9077. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9078. */
  9079. export abstract class ShadowLight extends Light implements IShadowLight {
  9080. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9081. protected _position: Vector3;
  9082. protected _setPosition(value: Vector3): void;
  9083. /**
  9084. * Sets the position the shadow will be casted from. Also use as the light position for both
  9085. * point and spot lights.
  9086. */
  9087. /**
  9088. * Sets the position the shadow will be casted from. Also use as the light position for both
  9089. * point and spot lights.
  9090. */
  9091. position: Vector3;
  9092. protected _direction: Vector3;
  9093. protected _setDirection(value: Vector3): void;
  9094. /**
  9095. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9096. * Also use as the light direction on spot and directional lights.
  9097. */
  9098. /**
  9099. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9100. * Also use as the light direction on spot and directional lights.
  9101. */
  9102. direction: Vector3;
  9103. private _shadowMinZ;
  9104. /**
  9105. * Gets the shadow projection clipping minimum z value.
  9106. */
  9107. /**
  9108. * Sets the shadow projection clipping minimum z value.
  9109. */
  9110. shadowMinZ: number;
  9111. private _shadowMaxZ;
  9112. /**
  9113. * Sets the shadow projection clipping maximum z value.
  9114. */
  9115. /**
  9116. * Gets the shadow projection clipping maximum z value.
  9117. */
  9118. shadowMaxZ: number;
  9119. /**
  9120. * Callback defining a custom Projection Matrix Builder.
  9121. * This can be used to override the default projection matrix computation.
  9122. */
  9123. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9124. /**
  9125. * The transformed position. Position of the light in world space taking parenting in account.
  9126. */
  9127. transformedPosition: Vector3;
  9128. /**
  9129. * The transformed direction. Direction of the light in world space taking parenting in account.
  9130. */
  9131. transformedDirection: Vector3;
  9132. private _needProjectionMatrixCompute;
  9133. /**
  9134. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9135. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9136. */
  9137. computeTransformedInformation(): boolean;
  9138. /**
  9139. * Return the depth scale used for the shadow map.
  9140. * @returns the depth scale.
  9141. */
  9142. getDepthScale(): number;
  9143. /**
  9144. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9145. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9146. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9147. */
  9148. getShadowDirection(faceIndex?: number): Vector3;
  9149. /**
  9150. * Returns the ShadowLight absolute position in the World.
  9151. * @returns the position vector in world space
  9152. */
  9153. getAbsolutePosition(): Vector3;
  9154. /**
  9155. * Sets the ShadowLight direction toward the passed target.
  9156. * @param target The point to target in local space
  9157. * @returns the updated ShadowLight direction
  9158. */
  9159. setDirectionToTarget(target: Vector3): Vector3;
  9160. /**
  9161. * Returns the light rotation in euler definition.
  9162. * @returns the x y z rotation in local space.
  9163. */
  9164. getRotation(): Vector3;
  9165. /**
  9166. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9167. * @returns true if a cube texture needs to be use
  9168. */
  9169. needCube(): boolean;
  9170. /**
  9171. * Detects if the projection matrix requires to be recomputed this frame.
  9172. * @returns true if it requires to be recomputed otherwise, false.
  9173. */
  9174. needProjectionMatrixCompute(): boolean;
  9175. /**
  9176. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9177. */
  9178. forceProjectionMatrixCompute(): void;
  9179. /** @hidden */ private _initCache(): void;
  9180. /** @hidden */ private _isSynchronized(): boolean;
  9181. /**
  9182. * Computes the world matrix of the node
  9183. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9184. * @returns the world matrix
  9185. */
  9186. computeWorldMatrix(force?: boolean): Matrix;
  9187. /**
  9188. * Gets the minZ used for shadow according to both the scene and the light.
  9189. * @param activeCamera The camera we are returning the min for
  9190. * @returns the depth min z
  9191. */
  9192. getDepthMinZ(activeCamera: Camera): number;
  9193. /**
  9194. * Gets the maxZ used for shadow according to both the scene and the light.
  9195. * @param activeCamera The camera we are returning the max for
  9196. * @returns the depth max z
  9197. */
  9198. getDepthMaxZ(activeCamera: Camera): number;
  9199. /**
  9200. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9201. * @param matrix The materix to updated with the projection information
  9202. * @param viewMatrix The transform matrix of the light
  9203. * @param renderList The list of mesh to render in the map
  9204. * @returns The current light
  9205. */
  9206. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9207. }
  9208. }
  9209. declare module BABYLON {
  9210. /**
  9211. * "Static Class" containing the most commonly used helper while dealing with material for
  9212. * rendering purpose.
  9213. *
  9214. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9215. *
  9216. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9217. */
  9218. export class MaterialHelper {
  9219. /**
  9220. * Bind the current view position to an effect.
  9221. * @param effect The effect to be bound
  9222. * @param scene The scene the eyes position is used from
  9223. */
  9224. static BindEyePosition(effect: Effect, scene: Scene): void;
  9225. /**
  9226. * Helps preparing the defines values about the UVs in used in the effect.
  9227. * UVs are shared as much as we can accross channels in the shaders.
  9228. * @param texture The texture we are preparing the UVs for
  9229. * @param defines The defines to update
  9230. * @param key The channel key "diffuse", "specular"... used in the shader
  9231. */
  9232. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9233. /**
  9234. * Binds a texture matrix value to its corrsponding uniform
  9235. * @param texture The texture to bind the matrix for
  9236. * @param uniformBuffer The uniform buffer receivin the data
  9237. * @param key The channel key "diffuse", "specular"... used in the shader
  9238. */
  9239. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9240. /**
  9241. * Gets the current status of the fog (should it be enabled?)
  9242. * @param mesh defines the mesh to evaluate for fog support
  9243. * @param scene defines the hosting scene
  9244. * @returns true if fog must be enabled
  9245. */
  9246. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9247. /**
  9248. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9249. * @param mesh defines the current mesh
  9250. * @param scene defines the current scene
  9251. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9252. * @param pointsCloud defines if point cloud rendering has to be turned on
  9253. * @param fogEnabled defines if fog has to be turned on
  9254. * @param alphaTest defines if alpha testing has to be turned on
  9255. * @param defines defines the current list of defines
  9256. */
  9257. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9258. /**
  9259. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9260. * @param scene defines the current scene
  9261. * @param engine defines the current engine
  9262. * @param defines specifies the list of active defines
  9263. * @param useInstances defines if instances have to be turned on
  9264. * @param useClipPlane defines if clip plane have to be turned on
  9265. */
  9266. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9267. /**
  9268. * Prepares the defines for bones
  9269. * @param mesh The mesh containing the geometry data we will draw
  9270. * @param defines The defines to update
  9271. */
  9272. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9273. /**
  9274. * Prepares the defines for morph targets
  9275. * @param mesh The mesh containing the geometry data we will draw
  9276. * @param defines The defines to update
  9277. */
  9278. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9279. /**
  9280. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9281. * @param mesh The mesh containing the geometry data we will draw
  9282. * @param defines The defines to update
  9283. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9284. * @param useBones Precise whether bones should be used or not (override mesh info)
  9285. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9286. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9287. * @returns false if defines are considered not dirty and have not been checked
  9288. */
  9289. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9290. /**
  9291. * Prepares the defines related to multiview
  9292. * @param scene The scene we are intending to draw
  9293. * @param defines The defines to update
  9294. */
  9295. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9296. /**
  9297. * Prepares the defines related to the light information passed in parameter
  9298. * @param scene The scene we are intending to draw
  9299. * @param mesh The mesh the effect is compiling for
  9300. * @param defines The defines to update
  9301. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9302. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9303. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9304. * @returns true if normals will be required for the rest of the effect
  9305. */
  9306. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9307. /**
  9308. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9309. * that won t be acctive due to defines being turned off.
  9310. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9311. * @param samplersList The samplers list
  9312. * @param defines The defines helping in the list generation
  9313. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9314. */
  9315. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9316. /**
  9317. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9318. * @param defines The defines to update while falling back
  9319. * @param fallbacks The authorized effect fallbacks
  9320. * @param maxSimultaneousLights The maximum number of lights allowed
  9321. * @param rank the current rank of the Effect
  9322. * @returns The newly affected rank
  9323. */
  9324. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9325. /**
  9326. * Prepares the list of attributes required for morph targets according to the effect defines.
  9327. * @param attribs The current list of supported attribs
  9328. * @param mesh The mesh to prepare the morph targets attributes for
  9329. * @param defines The current Defines of the effect
  9330. */
  9331. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9332. /**
  9333. * Prepares the list of attributes required for bones according to the effect defines.
  9334. * @param attribs The current list of supported attribs
  9335. * @param mesh The mesh to prepare the bones attributes for
  9336. * @param defines The current Defines of the effect
  9337. * @param fallbacks The current efffect fallback strategy
  9338. */
  9339. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9340. /**
  9341. * Prepares the list of attributes required for instances according to the effect defines.
  9342. * @param attribs The current list of supported attribs
  9343. * @param defines The current Defines of the effect
  9344. */
  9345. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9346. /**
  9347. * Binds the light shadow information to the effect for the given mesh.
  9348. * @param light The light containing the generator
  9349. * @param scene The scene the lights belongs to
  9350. * @param mesh The mesh we are binding the information to render
  9351. * @param lightIndex The light index in the effect used to render the mesh
  9352. * @param effect The effect we are binding the data to
  9353. */
  9354. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9355. /**
  9356. * Binds the light information to the effect.
  9357. * @param light The light containing the generator
  9358. * @param effect The effect we are binding the data to
  9359. * @param lightIndex The light index in the effect used to render
  9360. */
  9361. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9362. /**
  9363. * Binds the lights information from the scene to the effect for the given mesh.
  9364. * @param scene The scene the lights belongs to
  9365. * @param mesh The mesh we are binding the information to render
  9366. * @param effect The effect we are binding the data to
  9367. * @param defines The generated defines for the effect
  9368. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9369. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9370. */
  9371. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9372. private static _tempFogColor;
  9373. /**
  9374. * Binds the fog information from the scene to the effect for the given mesh.
  9375. * @param scene The scene the lights belongs to
  9376. * @param mesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. * @param linearSpace Defines if the fog effect is applied in linear space
  9379. */
  9380. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9381. /**
  9382. * Binds the bones information from the mesh to the effect.
  9383. * @param mesh The mesh we are binding the information to render
  9384. * @param effect The effect we are binding the data to
  9385. */
  9386. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9387. /**
  9388. * Binds the morph targets information from the mesh to the effect.
  9389. * @param abstractMesh The mesh we are binding the information to render
  9390. * @param effect The effect we are binding the data to
  9391. */
  9392. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9393. /**
  9394. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9395. * @param defines The generated defines used in the effect
  9396. * @param effect The effect we are binding the data to
  9397. * @param scene The scene we are willing to render with logarithmic scale for
  9398. */
  9399. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9400. /**
  9401. * Binds the clip plane information from the scene to the effect.
  9402. * @param scene The scene the clip plane information are extracted from
  9403. * @param effect The effect we are binding the data to
  9404. */
  9405. static BindClipPlane(effect: Effect, scene: Scene): void;
  9406. }
  9407. }
  9408. declare module BABYLON {
  9409. /** @hidden */
  9410. export var kernelBlurVaryingDeclaration: {
  9411. name: string;
  9412. shader: string;
  9413. };
  9414. }
  9415. declare module BABYLON {
  9416. /** @hidden */
  9417. export var kernelBlurFragment: {
  9418. name: string;
  9419. shader: string;
  9420. };
  9421. }
  9422. declare module BABYLON {
  9423. /** @hidden */
  9424. export var kernelBlurFragment2: {
  9425. name: string;
  9426. shader: string;
  9427. };
  9428. }
  9429. declare module BABYLON {
  9430. /** @hidden */
  9431. export var kernelBlurPixelShader: {
  9432. name: string;
  9433. shader: string;
  9434. };
  9435. }
  9436. declare module BABYLON {
  9437. /** @hidden */
  9438. export var kernelBlurVertex: {
  9439. name: string;
  9440. shader: string;
  9441. };
  9442. }
  9443. declare module BABYLON {
  9444. /** @hidden */
  9445. export var kernelBlurVertexShader: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module BABYLON {
  9451. /**
  9452. * The Blur Post Process which blurs an image based on a kernel and direction.
  9453. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9454. */
  9455. export class BlurPostProcess extends PostProcess {
  9456. /** The direction in which to blur the image. */
  9457. direction: Vector2;
  9458. private blockCompilation;
  9459. protected _kernel: number;
  9460. protected _idealKernel: number;
  9461. protected _packedFloat: boolean;
  9462. private _staticDefines;
  9463. /**
  9464. * Sets the length in pixels of the blur sample region
  9465. */
  9466. /**
  9467. * Gets the length in pixels of the blur sample region
  9468. */
  9469. kernel: number;
  9470. /**
  9471. * Sets wether or not the blur needs to unpack/repack floats
  9472. */
  9473. /**
  9474. * Gets wether or not the blur is unpacking/repacking floats
  9475. */
  9476. packedFloat: boolean;
  9477. /**
  9478. * Creates a new instance BlurPostProcess
  9479. * @param name The name of the effect.
  9480. * @param direction The direction in which to blur the image.
  9481. * @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.
  9482. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9483. * @param camera The camera to apply the render pass to.
  9484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9485. * @param engine The engine which the post process will be applied. (default: current engine)
  9486. * @param reusable If the post process can be reused on the same frame. (default: false)
  9487. * @param textureType Type of textures used when performing the post process. (default: 0)
  9488. * @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)
  9489. */
  9490. constructor(name: string,
  9491. /** The direction in which to blur the image. */
  9492. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9493. /**
  9494. * Updates the effect with the current post process compile time values and recompiles the shader.
  9495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9498. * @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
  9499. * @param onCompiled Called when the shader has been compiled.
  9500. * @param onError Called if there is an error when compiling a shader.
  9501. */
  9502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9503. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9504. /**
  9505. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9506. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9507. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9508. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9509. * The gaps between physical kernels are compensated for in the weighting of the samples
  9510. * @param idealKernel Ideal blur kernel.
  9511. * @return Nearest best kernel.
  9512. */
  9513. protected _nearestBestKernel(idealKernel: number): number;
  9514. /**
  9515. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9516. * @param x The point on the Gaussian distribution to sample.
  9517. * @return the value of the Gaussian function at x.
  9518. */
  9519. protected _gaussianWeight(x: number): number;
  9520. /**
  9521. * Generates a string that can be used as a floating point number in GLSL.
  9522. * @param x Value to print.
  9523. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9524. * @return GLSL float string.
  9525. */
  9526. protected _glslFloat(x: number, decimalFigures?: number): string;
  9527. }
  9528. }
  9529. declare module BABYLON {
  9530. /** @hidden */
  9531. export var shadowMapPixelShader: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module BABYLON {
  9537. /** @hidden */
  9538. export var bonesDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module BABYLON {
  9544. /** @hidden */
  9545. export var morphTargetsVertexGlobalDeclaration: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module BABYLON {
  9551. /** @hidden */
  9552. export var morphTargetsVertexDeclaration: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module BABYLON {
  9558. /** @hidden */
  9559. export var instancesDeclaration: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module BABYLON {
  9565. /** @hidden */
  9566. export var helperFunctions: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module BABYLON {
  9572. /** @hidden */
  9573. export var morphTargetsVertex: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module BABYLON {
  9579. /** @hidden */
  9580. export var instancesVertex: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module BABYLON {
  9586. /** @hidden */
  9587. export var bonesVertex: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module BABYLON {
  9593. /** @hidden */
  9594. export var shadowMapVertexShader: {
  9595. name: string;
  9596. shader: string;
  9597. };
  9598. }
  9599. declare module BABYLON {
  9600. /** @hidden */
  9601. export var depthBoxBlurPixelShader: {
  9602. name: string;
  9603. shader: string;
  9604. };
  9605. }
  9606. declare module BABYLON {
  9607. /**
  9608. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9609. */
  9610. export interface ICustomShaderOptions {
  9611. /**
  9612. * Gets or sets the custom shader name to use
  9613. */
  9614. shaderName: string;
  9615. /**
  9616. * The list of attribute names used in the shader
  9617. */
  9618. attributes?: string[];
  9619. /**
  9620. * The list of unifrom names used in the shader
  9621. */
  9622. uniforms?: string[];
  9623. /**
  9624. * The list of sampler names used in the shader
  9625. */
  9626. samplers?: string[];
  9627. /**
  9628. * The list of defines used in the shader
  9629. */
  9630. defines?: string[];
  9631. }
  9632. /**
  9633. * Interface to implement to create a shadow generator compatible with BJS.
  9634. */
  9635. export interface IShadowGenerator {
  9636. /**
  9637. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9638. * @returns The render target texture if present otherwise, null
  9639. */
  9640. getShadowMap(): Nullable<RenderTargetTexture>;
  9641. /**
  9642. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9643. * @returns The render target texture if the shadow map is present otherwise, null
  9644. */
  9645. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9646. /**
  9647. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9648. * @param subMesh The submesh we want to render in the shadow map
  9649. * @param useInstances Defines wether will draw in the map using instances
  9650. * @returns true if ready otherwise, false
  9651. */
  9652. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9653. /**
  9654. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9655. * @param defines Defines of the material we want to update
  9656. * @param lightIndex Index of the light in the enabled light list of the material
  9657. */
  9658. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9659. /**
  9660. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9661. * defined in the generator but impacting the effect).
  9662. * It implies the unifroms available on the materials are the standard BJS ones.
  9663. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9664. * @param effect The effect we are binfing the information for
  9665. */
  9666. bindShadowLight(lightIndex: string, effect: Effect): void;
  9667. /**
  9668. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9669. * (eq to shadow prjection matrix * light transform matrix)
  9670. * @returns The transform matrix used to create the shadow map
  9671. */
  9672. getTransformMatrix(): Matrix;
  9673. /**
  9674. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9675. * Cube and 2D textures for instance.
  9676. */
  9677. recreateShadowMap(): void;
  9678. /**
  9679. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9680. * @param onCompiled Callback triggered at the and of the effects compilation
  9681. * @param options Sets of optional options forcing the compilation with different modes
  9682. */
  9683. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9684. useInstances: boolean;
  9685. }>): void;
  9686. /**
  9687. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9688. * @param options Sets of optional options forcing the compilation with different modes
  9689. * @returns A promise that resolves when the compilation completes
  9690. */
  9691. forceCompilationAsync(options?: Partial<{
  9692. useInstances: boolean;
  9693. }>): Promise<void>;
  9694. /**
  9695. * Serializes the shadow generator setup to a json object.
  9696. * @returns The serialized JSON object
  9697. */
  9698. serialize(): any;
  9699. /**
  9700. * Disposes the Shadow map and related Textures and effects.
  9701. */
  9702. dispose(): void;
  9703. }
  9704. /**
  9705. * Default implementation IShadowGenerator.
  9706. * This is the main object responsible of generating shadows in the framework.
  9707. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9708. */
  9709. export class ShadowGenerator implements IShadowGenerator {
  9710. /**
  9711. * Shadow generator mode None: no filtering applied.
  9712. */
  9713. static readonly FILTER_NONE: number;
  9714. /**
  9715. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9716. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9717. */
  9718. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9719. /**
  9720. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9721. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9722. */
  9723. static readonly FILTER_POISSONSAMPLING: number;
  9724. /**
  9725. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9726. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9727. */
  9728. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9729. /**
  9730. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9731. * edge artifacts on steep falloff.
  9732. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9733. */
  9734. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9735. /**
  9736. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9737. * edge artifacts on steep falloff.
  9738. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9739. */
  9740. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9741. /**
  9742. * Shadow generator mode PCF: Percentage Closer Filtering
  9743. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9744. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9745. */
  9746. static readonly FILTER_PCF: number;
  9747. /**
  9748. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9749. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9750. * Contact Hardening
  9751. */
  9752. static readonly FILTER_PCSS: number;
  9753. /**
  9754. * Reserved for PCF and PCSS
  9755. * Highest Quality.
  9756. *
  9757. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9758. *
  9759. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9760. */
  9761. static readonly QUALITY_HIGH: number;
  9762. /**
  9763. * Reserved for PCF and PCSS
  9764. * Good tradeoff for quality/perf cross devices
  9765. *
  9766. * Execute PCF on a 3*3 kernel.
  9767. *
  9768. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9769. */
  9770. static readonly QUALITY_MEDIUM: number;
  9771. /**
  9772. * Reserved for PCF and PCSS
  9773. * The lowest quality but the fastest.
  9774. *
  9775. * Execute PCF on a 1*1 kernel.
  9776. *
  9777. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9778. */
  9779. static readonly QUALITY_LOW: number;
  9780. /** Gets or sets the custom shader name to use */
  9781. customShaderOptions: ICustomShaderOptions;
  9782. /**
  9783. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9784. */
  9785. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9786. /**
  9787. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9788. */
  9789. onAfterShadowMapRenderObservable: Observable<Effect>;
  9790. /**
  9791. * Observable triggered before a mesh is rendered in the shadow map.
  9792. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9793. */
  9794. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9795. /**
  9796. * Observable triggered after a mesh is rendered in the shadow map.
  9797. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9798. */
  9799. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9800. private _bias;
  9801. /**
  9802. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9803. */
  9804. /**
  9805. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9806. */
  9807. bias: number;
  9808. private _normalBias;
  9809. /**
  9810. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9811. */
  9812. /**
  9813. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9814. */
  9815. normalBias: number;
  9816. private _blurBoxOffset;
  9817. /**
  9818. * Gets the blur box offset: offset applied during the blur pass.
  9819. * Only useful if useKernelBlur = false
  9820. */
  9821. /**
  9822. * Sets the blur box offset: offset applied during the blur pass.
  9823. * Only useful if useKernelBlur = false
  9824. */
  9825. blurBoxOffset: number;
  9826. private _blurScale;
  9827. /**
  9828. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9829. * 2 means half of the size.
  9830. */
  9831. /**
  9832. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9833. * 2 means half of the size.
  9834. */
  9835. blurScale: number;
  9836. private _blurKernel;
  9837. /**
  9838. * Gets the blur kernel: kernel size of the blur pass.
  9839. * Only useful if useKernelBlur = true
  9840. */
  9841. /**
  9842. * Sets the blur kernel: kernel size of the blur pass.
  9843. * Only useful if useKernelBlur = true
  9844. */
  9845. blurKernel: number;
  9846. private _useKernelBlur;
  9847. /**
  9848. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9849. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9850. */
  9851. /**
  9852. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9853. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9854. */
  9855. useKernelBlur: boolean;
  9856. private _depthScale;
  9857. /**
  9858. * Gets the depth scale used in ESM mode.
  9859. */
  9860. /**
  9861. * Sets the depth scale used in ESM mode.
  9862. * This can override the scale stored on the light.
  9863. */
  9864. depthScale: number;
  9865. private _filter;
  9866. /**
  9867. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9868. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9869. */
  9870. /**
  9871. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9872. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9873. */
  9874. filter: number;
  9875. /**
  9876. * Gets if the current filter is set to Poisson Sampling.
  9877. */
  9878. /**
  9879. * Sets the current filter to Poisson Sampling.
  9880. */
  9881. usePoissonSampling: boolean;
  9882. /**
  9883. * Gets if the current filter is set to ESM.
  9884. */
  9885. /**
  9886. * Sets the current filter is to ESM.
  9887. */
  9888. useExponentialShadowMap: boolean;
  9889. /**
  9890. * Gets if the current filter is set to filtered ESM.
  9891. */
  9892. /**
  9893. * Gets if the current filter is set to filtered ESM.
  9894. */
  9895. useBlurExponentialShadowMap: boolean;
  9896. /**
  9897. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9898. * exponential to prevent steep falloff artifacts).
  9899. */
  9900. /**
  9901. * Sets the current filter to "close ESM" (using the inverse of the
  9902. * exponential to prevent steep falloff artifacts).
  9903. */
  9904. useCloseExponentialShadowMap: boolean;
  9905. /**
  9906. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9907. * exponential to prevent steep falloff artifacts).
  9908. */
  9909. /**
  9910. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9911. * exponential to prevent steep falloff artifacts).
  9912. */
  9913. useBlurCloseExponentialShadowMap: boolean;
  9914. /**
  9915. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9916. */
  9917. /**
  9918. * Sets the current filter to "PCF" (percentage closer filtering).
  9919. */
  9920. usePercentageCloserFiltering: boolean;
  9921. private _filteringQuality;
  9922. /**
  9923. * Gets the PCF or PCSS Quality.
  9924. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9925. */
  9926. /**
  9927. * Sets the PCF or PCSS Quality.
  9928. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9929. */
  9930. filteringQuality: number;
  9931. /**
  9932. * Gets if the current filter is set to "PCSS" (contact hardening).
  9933. */
  9934. /**
  9935. * Sets the current filter to "PCSS" (contact hardening).
  9936. */
  9937. useContactHardeningShadow: boolean;
  9938. private _contactHardeningLightSizeUVRatio;
  9939. /**
  9940. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9941. * Using a ratio helps keeping shape stability independently of the map size.
  9942. *
  9943. * It does not account for the light projection as it was having too much
  9944. * instability during the light setup or during light position changes.
  9945. *
  9946. * Only valid if useContactHardeningShadow is true.
  9947. */
  9948. /**
  9949. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9950. * Using a ratio helps keeping shape stability independently of the map size.
  9951. *
  9952. * It does not account for the light projection as it was having too much
  9953. * instability during the light setup or during light position changes.
  9954. *
  9955. * Only valid if useContactHardeningShadow is true.
  9956. */
  9957. contactHardeningLightSizeUVRatio: number;
  9958. private _darkness;
  9959. /** Gets or sets the actual darkness of a shadow */
  9960. darkness: number;
  9961. /**
  9962. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9963. * 0 means strongest and 1 would means no shadow.
  9964. * @returns the darkness.
  9965. */
  9966. getDarkness(): number;
  9967. /**
  9968. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9969. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9970. * @returns the shadow generator allowing fluent coding.
  9971. */
  9972. setDarkness(darkness: number): ShadowGenerator;
  9973. private _transparencyShadow;
  9974. /** Gets or sets the ability to have transparent shadow */
  9975. transparencyShadow: boolean;
  9976. /**
  9977. * Sets the ability to have transparent shadow (boolean).
  9978. * @param transparent True if transparent else False
  9979. * @returns the shadow generator allowing fluent coding
  9980. */
  9981. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9982. private _shadowMap;
  9983. private _shadowMap2;
  9984. /**
  9985. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9986. * @returns The render target texture if present otherwise, null
  9987. */
  9988. getShadowMap(): Nullable<RenderTargetTexture>;
  9989. /**
  9990. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9991. * @returns The render target texture if the shadow map is present otherwise, null
  9992. */
  9993. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9994. /**
  9995. * Gets the class name of that object
  9996. * @returns "ShadowGenerator"
  9997. */
  9998. getClassName(): string;
  9999. /**
  10000. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10001. * @param mesh Mesh to add
  10002. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10003. * @returns the Shadow Generator itself
  10004. */
  10005. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10006. /**
  10007. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10008. * @param mesh Mesh to remove
  10009. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10010. * @returns the Shadow Generator itself
  10011. */
  10012. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10013. /**
  10014. * Controls the extent to which the shadows fade out at the edge of the frustum
  10015. * Used only by directionals and spots
  10016. */
  10017. frustumEdgeFalloff: number;
  10018. private _light;
  10019. /**
  10020. * Returns the associated light object.
  10021. * @returns the light generating the shadow
  10022. */
  10023. getLight(): IShadowLight;
  10024. /**
  10025. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10026. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10027. * It might on the other hand introduce peter panning.
  10028. */
  10029. forceBackFacesOnly: boolean;
  10030. private _scene;
  10031. private _lightDirection;
  10032. private _effect;
  10033. private _viewMatrix;
  10034. private _projectionMatrix;
  10035. private _transformMatrix;
  10036. private _cachedPosition;
  10037. private _cachedDirection;
  10038. private _cachedDefines;
  10039. private _currentRenderID;
  10040. private _boxBlurPostprocess;
  10041. private _kernelBlurXPostprocess;
  10042. private _kernelBlurYPostprocess;
  10043. private _blurPostProcesses;
  10044. private _mapSize;
  10045. private _currentFaceIndex;
  10046. private _currentFaceIndexCache;
  10047. private _textureType;
  10048. private _defaultTextureMatrix;
  10049. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  10050. /**
  10051. * Creates a ShadowGenerator object.
  10052. * A ShadowGenerator is the required tool to use the shadows.
  10053. * Each light casting shadows needs to use its own ShadowGenerator.
  10054. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10055. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10056. * @param light The light object generating the shadows.
  10057. * @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.
  10058. */
  10059. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10060. private _initializeGenerator;
  10061. private _initializeShadowMap;
  10062. private _initializeBlurRTTAndPostProcesses;
  10063. private _renderForShadowMap;
  10064. private _renderSubMeshForShadowMap;
  10065. private _applyFilterValues;
  10066. /**
  10067. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10068. * @param onCompiled Callback triggered at the and of the effects compilation
  10069. * @param options Sets of optional options forcing the compilation with different modes
  10070. */
  10071. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10072. useInstances: boolean;
  10073. }>): void;
  10074. /**
  10075. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10076. * @param options Sets of optional options forcing the compilation with different modes
  10077. * @returns A promise that resolves when the compilation completes
  10078. */
  10079. forceCompilationAsync(options?: Partial<{
  10080. useInstances: boolean;
  10081. }>): Promise<void>;
  10082. /**
  10083. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10084. * @param subMesh The submesh we want to render in the shadow map
  10085. * @param useInstances Defines wether will draw in the map using instances
  10086. * @returns true if ready otherwise, false
  10087. */
  10088. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10089. /**
  10090. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10091. * @param defines Defines of the material we want to update
  10092. * @param lightIndex Index of the light in the enabled light list of the material
  10093. */
  10094. prepareDefines(defines: any, lightIndex: number): void;
  10095. /**
  10096. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10097. * defined in the generator but impacting the effect).
  10098. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10099. * @param effect The effect we are binfing the information for
  10100. */
  10101. bindShadowLight(lightIndex: string, effect: Effect): void;
  10102. /**
  10103. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10104. * (eq to shadow prjection matrix * light transform matrix)
  10105. * @returns The transform matrix used to create the shadow map
  10106. */
  10107. getTransformMatrix(): Matrix;
  10108. /**
  10109. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10110. * Cube and 2D textures for instance.
  10111. */
  10112. recreateShadowMap(): void;
  10113. private _disposeBlurPostProcesses;
  10114. private _disposeRTTandPostProcesses;
  10115. /**
  10116. * Disposes the ShadowGenerator.
  10117. * Returns nothing.
  10118. */
  10119. dispose(): void;
  10120. /**
  10121. * Serializes the shadow generator setup to a json object.
  10122. * @returns The serialized JSON object
  10123. */
  10124. serialize(): any;
  10125. /**
  10126. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10127. * @param parsedShadowGenerator The JSON object to parse
  10128. * @param scene The scene to create the shadow map for
  10129. * @returns The parsed shadow generator
  10130. */
  10131. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10132. }
  10133. }
  10134. declare module BABYLON {
  10135. /**
  10136. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10137. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10138. * 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.
  10139. */
  10140. export abstract class Light extends Node {
  10141. /**
  10142. * Falloff Default: light is falling off following the material specification:
  10143. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10144. */
  10145. static readonly FALLOFF_DEFAULT: number;
  10146. /**
  10147. * Falloff Physical: light is falling off following the inverse squared distance law.
  10148. */
  10149. static readonly FALLOFF_PHYSICAL: number;
  10150. /**
  10151. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10152. * to enhance interoperability with other engines.
  10153. */
  10154. static readonly FALLOFF_GLTF: number;
  10155. /**
  10156. * Falloff Standard: light is falling off like in the standard material
  10157. * to enhance interoperability with other materials.
  10158. */
  10159. static readonly FALLOFF_STANDARD: number;
  10160. /**
  10161. * If every light affecting the material is in this lightmapMode,
  10162. * material.lightmapTexture adds or multiplies
  10163. * (depends on material.useLightmapAsShadowmap)
  10164. * after every other light calculations.
  10165. */
  10166. static readonly LIGHTMAP_DEFAULT: number;
  10167. /**
  10168. * material.lightmapTexture as only diffuse lighting from this light
  10169. * adds only specular lighting from this light
  10170. * adds dynamic shadows
  10171. */
  10172. static readonly LIGHTMAP_SPECULAR: number;
  10173. /**
  10174. * material.lightmapTexture as only lighting
  10175. * no light calculation from this light
  10176. * only adds dynamic shadows from this light
  10177. */
  10178. static readonly LIGHTMAP_SHADOWSONLY: number;
  10179. /**
  10180. * Each light type uses the default quantity according to its type:
  10181. * point/spot lights use luminous intensity
  10182. * directional lights use illuminance
  10183. */
  10184. static readonly INTENSITYMODE_AUTOMATIC: number;
  10185. /**
  10186. * lumen (lm)
  10187. */
  10188. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10189. /**
  10190. * candela (lm/sr)
  10191. */
  10192. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10193. /**
  10194. * lux (lm/m^2)
  10195. */
  10196. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10197. /**
  10198. * nit (cd/m^2)
  10199. */
  10200. static readonly INTENSITYMODE_LUMINANCE: number;
  10201. /**
  10202. * Light type const id of the point light.
  10203. */
  10204. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10205. /**
  10206. * Light type const id of the directional light.
  10207. */
  10208. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10209. /**
  10210. * Light type const id of the spot light.
  10211. */
  10212. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10213. /**
  10214. * Light type const id of the hemispheric light.
  10215. */
  10216. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10217. /**
  10218. * Diffuse gives the basic color to an object.
  10219. */
  10220. diffuse: Color3;
  10221. /**
  10222. * Specular produces a highlight color on an object.
  10223. * Note: This is note affecting PBR materials.
  10224. */
  10225. specular: Color3;
  10226. /**
  10227. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10228. * falling off base on range or angle.
  10229. * This can be set to any values in Light.FALLOFF_x.
  10230. *
  10231. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10232. * other types of materials.
  10233. */
  10234. falloffType: number;
  10235. /**
  10236. * Strength of the light.
  10237. * Note: By default it is define in the framework own unit.
  10238. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10239. */
  10240. intensity: number;
  10241. private _range;
  10242. protected _inverseSquaredRange: number;
  10243. /**
  10244. * Defines how far from the source the light is impacting in scene units.
  10245. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10246. */
  10247. /**
  10248. * Defines how far from the source the light is impacting in scene units.
  10249. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10250. */
  10251. range: number;
  10252. /**
  10253. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10254. * of light.
  10255. */
  10256. private _photometricScale;
  10257. private _intensityMode;
  10258. /**
  10259. * Gets the photometric scale used to interpret the intensity.
  10260. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10261. */
  10262. /**
  10263. * Sets the photometric scale used to interpret the intensity.
  10264. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10265. */
  10266. intensityMode: number;
  10267. private _radius;
  10268. /**
  10269. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10270. */
  10271. /**
  10272. * sets the light radius used by PBR Materials to simulate soft area lights.
  10273. */
  10274. radius: number;
  10275. private _renderPriority;
  10276. /**
  10277. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10278. * exceeding the number allowed of the materials.
  10279. */
  10280. renderPriority: number;
  10281. private _shadowEnabled;
  10282. /**
  10283. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10284. * the current shadow generator.
  10285. */
  10286. /**
  10287. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10288. * the current shadow generator.
  10289. */
  10290. shadowEnabled: boolean;
  10291. private _includedOnlyMeshes;
  10292. /**
  10293. * Gets the only meshes impacted by this light.
  10294. */
  10295. /**
  10296. * Sets the only meshes impacted by this light.
  10297. */
  10298. includedOnlyMeshes: AbstractMesh[];
  10299. private _excludedMeshes;
  10300. /**
  10301. * Gets the meshes not impacted by this light.
  10302. */
  10303. /**
  10304. * Sets the meshes not impacted by this light.
  10305. */
  10306. excludedMeshes: AbstractMesh[];
  10307. private _excludeWithLayerMask;
  10308. /**
  10309. * Gets the layer id use to find what meshes are not impacted by the light.
  10310. * Inactive if 0
  10311. */
  10312. /**
  10313. * Sets the layer id use to find what meshes are not impacted by the light.
  10314. * Inactive if 0
  10315. */
  10316. excludeWithLayerMask: number;
  10317. private _includeOnlyWithLayerMask;
  10318. /**
  10319. * Gets the layer id use to find what meshes are impacted by the light.
  10320. * Inactive if 0
  10321. */
  10322. /**
  10323. * Sets the layer id use to find what meshes are impacted by the light.
  10324. * Inactive if 0
  10325. */
  10326. includeOnlyWithLayerMask: number;
  10327. private _lightmapMode;
  10328. /**
  10329. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10330. */
  10331. /**
  10332. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10333. */
  10334. lightmapMode: number;
  10335. /**
  10336. * Shadow generator associted to the light.
  10337. * @hidden Internal use only.
  10338. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  10339. /**
  10340. * @hidden Internal use only.
  10341. */ private _excludedMeshesIds: string[];
  10342. /**
  10343. * @hidden Internal use only.
  10344. */ private _includedOnlyMeshesIds: string[];
  10345. /**
  10346. * The current light unifom buffer.
  10347. * @hidden Internal use only.
  10348. */ private _uniformBuffer: UniformBuffer;
  10349. /**
  10350. * Creates a Light object in the scene.
  10351. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10352. * @param name The firendly name of the light
  10353. * @param scene The scene the light belongs too
  10354. */
  10355. constructor(name: string, scene: Scene);
  10356. protected abstract _buildUniformLayout(): void;
  10357. /**
  10358. * Sets the passed Effect "effect" with the Light information.
  10359. * @param effect The effect to update
  10360. * @param lightIndex The index of the light in the effect to update
  10361. * @returns The light
  10362. */
  10363. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10364. /**
  10365. * Returns the string "Light".
  10366. * @returns the class name
  10367. */
  10368. getClassName(): string;
  10369. /** @hidden */ protected readonly _isLight: boolean;
  10370. /**
  10371. * Converts the light information to a readable string for debug purpose.
  10372. * @param fullDetails Supports for multiple levels of logging within scene loading
  10373. * @returns the human readable light info
  10374. */
  10375. toString(fullDetails?: boolean): string;
  10376. /** @hidden */
  10377. protected _syncParentEnabledState(): void;
  10378. /**
  10379. * Set the enabled state of this node.
  10380. * @param value - the new enabled state
  10381. */
  10382. setEnabled(value: boolean): void;
  10383. /**
  10384. * Returns the Light associated shadow generator if any.
  10385. * @return the associated shadow generator.
  10386. */
  10387. getShadowGenerator(): Nullable<IShadowGenerator>;
  10388. /**
  10389. * Returns a Vector3, the absolute light position in the World.
  10390. * @returns the world space position of the light
  10391. */
  10392. getAbsolutePosition(): Vector3;
  10393. /**
  10394. * Specifies if the light will affect the passed mesh.
  10395. * @param mesh The mesh to test against the light
  10396. * @return true the mesh is affected otherwise, false.
  10397. */
  10398. canAffectMesh(mesh: AbstractMesh): boolean;
  10399. /**
  10400. * Sort function to order lights for rendering.
  10401. * @param a First Light object to compare to second.
  10402. * @param b Second Light object to compare first.
  10403. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10404. */
  10405. static CompareLightsPriority(a: Light, b: Light): number;
  10406. /**
  10407. * Releases resources associated with this node.
  10408. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10409. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10410. */
  10411. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10412. /**
  10413. * Returns the light type ID (integer).
  10414. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10415. */
  10416. getTypeID(): number;
  10417. /**
  10418. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10419. * @returns the scaled intensity in intensity mode unit
  10420. */
  10421. getScaledIntensity(): number;
  10422. /**
  10423. * Returns a new Light object, named "name", from the current one.
  10424. * @param name The name of the cloned light
  10425. * @returns the new created light
  10426. */
  10427. clone(name: string): Nullable<Light>;
  10428. /**
  10429. * Serializes the current light into a Serialization object.
  10430. * @returns the serialized object.
  10431. */
  10432. serialize(): any;
  10433. /**
  10434. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10435. * This new light is named "name" and added to the passed scene.
  10436. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10437. * @param name The friendly name of the light
  10438. * @param scene The scene the new light will belong to
  10439. * @returns the constructor function
  10440. */
  10441. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10442. /**
  10443. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10444. * @param parsedLight The JSON representation of the light
  10445. * @param scene The scene to create the parsed light in
  10446. * @returns the created light after parsing
  10447. */
  10448. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10449. private _hookArrayForExcluded;
  10450. private _hookArrayForIncludedOnly;
  10451. private _resyncMeshes;
  10452. /**
  10453. * Forces the meshes to update their light related information in their rendering used effects
  10454. * @hidden Internal Use Only
  10455. */ private _markMeshesAsLightDirty(): void;
  10456. /**
  10457. * Recomputes the cached photometric scale if needed.
  10458. */
  10459. private _computePhotometricScale;
  10460. /**
  10461. * Returns the Photometric Scale according to the light type and intensity mode.
  10462. */
  10463. private _getPhotometricScale;
  10464. /**
  10465. * Reorder the light in the scene according to their defined priority.
  10466. * @hidden Internal Use Only
  10467. */ private _reorderLightsInScene(): void;
  10468. /**
  10469. * Prepares the list of defines specific to the light type.
  10470. * @param defines the list of defines
  10471. * @param lightIndex defines the index of the light for the effect
  10472. */
  10473. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10474. }
  10475. }
  10476. declare module BABYLON {
  10477. /**
  10478. * Interface used to define Action
  10479. */
  10480. export interface IAction {
  10481. /**
  10482. * Trigger for the action
  10483. */
  10484. trigger: number;
  10485. /** Options of the trigger */
  10486. triggerOptions: any;
  10487. /**
  10488. * Gets the trigger parameters
  10489. * @returns the trigger parameters
  10490. */
  10491. getTriggerParameter(): any;
  10492. /**
  10493. * Internal only - executes current action event
  10494. * @hidden
  10495. */ private _executeCurrent(evt?: ActionEvent): void;
  10496. /**
  10497. * Serialize placeholder for child classes
  10498. * @param parent of child
  10499. * @returns the serialized object
  10500. */
  10501. serialize(parent: any): any;
  10502. /**
  10503. * Internal only
  10504. * @hidden
  10505. */ private _prepare(): void;
  10506. /**
  10507. * Internal only - manager for action
  10508. * @hidden
  10509. */ private _actionManager: AbstractActionManager;
  10510. /**
  10511. * Adds action to chain of actions, may be a DoNothingAction
  10512. * @param action defines the next action to execute
  10513. * @returns The action passed in
  10514. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10515. */
  10516. then(action: IAction): IAction;
  10517. }
  10518. /**
  10519. * The action to be carried out following a trigger
  10520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10521. */
  10522. export class Action implements IAction {
  10523. /** the trigger, with or without parameters, for the action */
  10524. triggerOptions: any;
  10525. /**
  10526. * Trigger for the action
  10527. */
  10528. trigger: number;
  10529. /**
  10530. * Internal only - manager for action
  10531. * @hidden
  10532. */ private _actionManager: ActionManager;
  10533. private _nextActiveAction;
  10534. private _child;
  10535. private _condition?;
  10536. private _triggerParameter;
  10537. /**
  10538. * An event triggered prior to action being executed.
  10539. */
  10540. onBeforeExecuteObservable: Observable<Action>;
  10541. /**
  10542. * Creates a new Action
  10543. * @param triggerOptions the trigger, with or without parameters, for the action
  10544. * @param condition an optional determinant of action
  10545. */
  10546. constructor(
  10547. /** the trigger, with or without parameters, for the action */
  10548. triggerOptions: any, condition?: Condition);
  10549. /**
  10550. * Internal only
  10551. * @hidden
  10552. */ private _prepare(): void;
  10553. /**
  10554. * Gets the trigger parameters
  10555. * @returns the trigger parameters
  10556. */
  10557. getTriggerParameter(): any;
  10558. /**
  10559. * Internal only - executes current action event
  10560. * @hidden
  10561. */ private _executeCurrent(evt?: ActionEvent): void;
  10562. /**
  10563. * Execute placeholder for child classes
  10564. * @param evt optional action event
  10565. */
  10566. execute(evt?: ActionEvent): void;
  10567. /**
  10568. * Skips to next active action
  10569. */
  10570. skipToNextActiveAction(): void;
  10571. /**
  10572. * Adds action to chain of actions, may be a DoNothingAction
  10573. * @param action defines the next action to execute
  10574. * @returns The action passed in
  10575. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10576. */
  10577. then(action: Action): Action;
  10578. /**
  10579. * Internal only
  10580. * @hidden
  10581. */ private _getProperty(propertyPath: string): string;
  10582. /**
  10583. * Internal only
  10584. * @hidden
  10585. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10586. /**
  10587. * Serialize placeholder for child classes
  10588. * @param parent of child
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. /**
  10593. * Internal only called by serialize
  10594. * @hidden
  10595. */
  10596. protected _serialize(serializedAction: any, parent?: any): any;
  10597. /**
  10598. * Internal only
  10599. * @hidden
  10600. */ private static _SerializeValueAsString: (value: any) => string;
  10601. /**
  10602. * Internal only
  10603. * @hidden
  10604. */ private static _GetTargetProperty: (target: Scene | Node) => {
  10605. name: string;
  10606. targetType: string;
  10607. value: string;
  10608. };
  10609. }
  10610. }
  10611. declare module BABYLON {
  10612. /**
  10613. * A Condition applied to an Action
  10614. */
  10615. export class Condition {
  10616. /**
  10617. * Internal only - manager for action
  10618. * @hidden
  10619. */ private _actionManager: ActionManager;
  10620. /**
  10621. * Internal only
  10622. * @hidden
  10623. */ private _evaluationId: number;
  10624. /**
  10625. * Internal only
  10626. * @hidden
  10627. */ private _currentResult: boolean;
  10628. /**
  10629. * Creates a new Condition
  10630. * @param actionManager the manager of the action the condition is applied to
  10631. */
  10632. constructor(actionManager: ActionManager);
  10633. /**
  10634. * Check if the current condition is valid
  10635. * @returns a boolean
  10636. */
  10637. isValid(): boolean;
  10638. /**
  10639. * Internal only
  10640. * @hidden
  10641. */ private _getProperty(propertyPath: string): string;
  10642. /**
  10643. * Internal only
  10644. * @hidden
  10645. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10646. /**
  10647. * Serialize placeholder for child classes
  10648. * @returns the serialized object
  10649. */
  10650. serialize(): any;
  10651. /**
  10652. * Internal only
  10653. * @hidden
  10654. */
  10655. protected _serialize(serializedCondition: any): any;
  10656. }
  10657. /**
  10658. * Defines specific conditional operators as extensions of Condition
  10659. */
  10660. export class ValueCondition extends Condition {
  10661. /** path to specify the property of the target the conditional operator uses */
  10662. propertyPath: string;
  10663. /** the value compared by the conditional operator against the current value of the property */
  10664. value: any;
  10665. /** the conditional operator, default ValueCondition.IsEqual */
  10666. operator: number;
  10667. /**
  10668. * Internal only
  10669. * @hidden
  10670. */
  10671. private static _IsEqual;
  10672. /**
  10673. * Internal only
  10674. * @hidden
  10675. */
  10676. private static _IsDifferent;
  10677. /**
  10678. * Internal only
  10679. * @hidden
  10680. */
  10681. private static _IsGreater;
  10682. /**
  10683. * Internal only
  10684. * @hidden
  10685. */
  10686. private static _IsLesser;
  10687. /**
  10688. * returns the number for IsEqual
  10689. */
  10690. static readonly IsEqual: number;
  10691. /**
  10692. * Returns the number for IsDifferent
  10693. */
  10694. static readonly IsDifferent: number;
  10695. /**
  10696. * Returns the number for IsGreater
  10697. */
  10698. static readonly IsGreater: number;
  10699. /**
  10700. * Returns the number for IsLesser
  10701. */
  10702. static readonly IsLesser: number;
  10703. /**
  10704. * Internal only The action manager for the condition
  10705. * @hidden
  10706. */ private _actionManager: ActionManager;
  10707. /**
  10708. * Internal only
  10709. * @hidden
  10710. */
  10711. private _target;
  10712. /**
  10713. * Internal only
  10714. * @hidden
  10715. */
  10716. private _effectiveTarget;
  10717. /**
  10718. * Internal only
  10719. * @hidden
  10720. */
  10721. private _property;
  10722. /**
  10723. * Creates a new ValueCondition
  10724. * @param actionManager manager for the action the condition applies to
  10725. * @param target for the action
  10726. * @param propertyPath path to specify the property of the target the conditional operator uses
  10727. * @param value the value compared by the conditional operator against the current value of the property
  10728. * @param operator the conditional operator, default ValueCondition.IsEqual
  10729. */
  10730. constructor(actionManager: ActionManager, target: any,
  10731. /** path to specify the property of the target the conditional operator uses */
  10732. propertyPath: string,
  10733. /** the value compared by the conditional operator against the current value of the property */
  10734. value: any,
  10735. /** the conditional operator, default ValueCondition.IsEqual */
  10736. operator?: number);
  10737. /**
  10738. * Compares the given value with the property value for the specified conditional operator
  10739. * @returns the result of the comparison
  10740. */
  10741. isValid(): boolean;
  10742. /**
  10743. * Serialize the ValueCondition into a JSON compatible object
  10744. * @returns serialization object
  10745. */
  10746. serialize(): any;
  10747. /**
  10748. * Gets the name of the conditional operator for the ValueCondition
  10749. * @param operator the conditional operator
  10750. * @returns the name
  10751. */
  10752. static GetOperatorName(operator: number): string;
  10753. }
  10754. /**
  10755. * Defines a predicate condition as an extension of Condition
  10756. */
  10757. export class PredicateCondition extends Condition {
  10758. /** defines the predicate function used to validate the condition */
  10759. predicate: () => boolean;
  10760. /**
  10761. * Internal only - manager for action
  10762. * @hidden
  10763. */ private _actionManager: ActionManager;
  10764. /**
  10765. * Creates a new PredicateCondition
  10766. * @param actionManager manager for the action the condition applies to
  10767. * @param predicate defines the predicate function used to validate the condition
  10768. */
  10769. constructor(actionManager: ActionManager,
  10770. /** defines the predicate function used to validate the condition */
  10771. predicate: () => boolean);
  10772. /**
  10773. * @returns the validity of the predicate condition
  10774. */
  10775. isValid(): boolean;
  10776. }
  10777. /**
  10778. * Defines a state condition as an extension of Condition
  10779. */
  10780. export class StateCondition extends Condition {
  10781. /** Value to compare with target state */
  10782. value: string;
  10783. /**
  10784. * Internal only - manager for action
  10785. * @hidden
  10786. */ private _actionManager: ActionManager;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. private _target;
  10792. /**
  10793. * Creates a new StateCondition
  10794. * @param actionManager manager for the action the condition applies to
  10795. * @param target of the condition
  10796. * @param value to compare with target state
  10797. */
  10798. constructor(actionManager: ActionManager, target: any,
  10799. /** Value to compare with target state */
  10800. value: string);
  10801. /**
  10802. * Gets a boolean indicating if the current condition is met
  10803. * @returns the validity of the state
  10804. */
  10805. isValid(): boolean;
  10806. /**
  10807. * Serialize the StateCondition into a JSON compatible object
  10808. * @returns serialization object
  10809. */
  10810. serialize(): any;
  10811. }
  10812. }
  10813. declare module BABYLON {
  10814. /**
  10815. * This defines an action responsible to toggle a boolean once triggered.
  10816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10817. */
  10818. export class SwitchBooleanAction extends Action {
  10819. /**
  10820. * The path to the boolean property in the target object
  10821. */
  10822. propertyPath: string;
  10823. private _target;
  10824. private _effectiveTarget;
  10825. private _property;
  10826. /**
  10827. * Instantiate the action
  10828. * @param triggerOptions defines the trigger options
  10829. * @param target defines the object containing the boolean
  10830. * @param propertyPath defines the path to the boolean property in the target object
  10831. * @param condition defines the trigger related conditions
  10832. */
  10833. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10834. /** @hidden */ private _prepare(): void;
  10835. /**
  10836. * Execute the action toggle the boolean value.
  10837. */
  10838. execute(): void;
  10839. /**
  10840. * Serializes the actions and its related information.
  10841. * @param parent defines the object to serialize in
  10842. * @returns the serialized object
  10843. */
  10844. serialize(parent: any): any;
  10845. }
  10846. /**
  10847. * This defines an action responsible to set a the state field of the target
  10848. * to a desired value once triggered.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class SetStateAction extends Action {
  10852. /**
  10853. * The value to store in the state field.
  10854. */
  10855. value: string;
  10856. private _target;
  10857. /**
  10858. * Instantiate the action
  10859. * @param triggerOptions defines the trigger options
  10860. * @param target defines the object containing the state property
  10861. * @param value defines the value to store in the state field
  10862. * @param condition defines the trigger related conditions
  10863. */
  10864. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10865. /**
  10866. * Execute the action and store the value on the target state property.
  10867. */
  10868. execute(): void;
  10869. /**
  10870. * Serializes the actions and its related information.
  10871. * @param parent defines the object to serialize in
  10872. * @returns the serialized object
  10873. */
  10874. serialize(parent: any): any;
  10875. }
  10876. /**
  10877. * This defines an action responsible to set a property of the target
  10878. * to a desired value once triggered.
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10880. */
  10881. export class SetValueAction extends Action {
  10882. /**
  10883. * The path of the property to set in the target.
  10884. */
  10885. propertyPath: string;
  10886. /**
  10887. * The value to set in the property
  10888. */
  10889. value: any;
  10890. private _target;
  10891. private _effectiveTarget;
  10892. private _property;
  10893. /**
  10894. * Instantiate the action
  10895. * @param triggerOptions defines the trigger options
  10896. * @param target defines the object containing the property
  10897. * @param propertyPath defines the path of the property to set in the target
  10898. * @param value defines the value to set in the property
  10899. * @param condition defines the trigger related conditions
  10900. */
  10901. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10902. /** @hidden */ private _prepare(): void;
  10903. /**
  10904. * Execute the action and set the targetted property to the desired value.
  10905. */
  10906. execute(): void;
  10907. /**
  10908. * Serializes the actions and its related information.
  10909. * @param parent defines the object to serialize in
  10910. * @returns the serialized object
  10911. */
  10912. serialize(parent: any): any;
  10913. }
  10914. /**
  10915. * This defines an action responsible to increment the target value
  10916. * to a desired value once triggered.
  10917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10918. */
  10919. export class IncrementValueAction extends Action {
  10920. /**
  10921. * The path of the property to increment in the target.
  10922. */
  10923. propertyPath: string;
  10924. /**
  10925. * The value we should increment the property by.
  10926. */
  10927. value: any;
  10928. private _target;
  10929. private _effectiveTarget;
  10930. private _property;
  10931. /**
  10932. * Instantiate the action
  10933. * @param triggerOptions defines the trigger options
  10934. * @param target defines the object containing the property
  10935. * @param propertyPath defines the path of the property to increment in the target
  10936. * @param value defines the value value we should increment the property by
  10937. * @param condition defines the trigger related conditions
  10938. */
  10939. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10940. /** @hidden */ private _prepare(): void;
  10941. /**
  10942. * Execute the action and increment the target of the value amount.
  10943. */
  10944. execute(): void;
  10945. /**
  10946. * Serializes the actions and its related information.
  10947. * @param parent defines the object to serialize in
  10948. * @returns the serialized object
  10949. */
  10950. serialize(parent: any): any;
  10951. }
  10952. /**
  10953. * This defines an action responsible to start an animation once triggered.
  10954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10955. */
  10956. export class PlayAnimationAction extends Action {
  10957. /**
  10958. * Where the animation should start (animation frame)
  10959. */
  10960. from: number;
  10961. /**
  10962. * Where the animation should stop (animation frame)
  10963. */
  10964. to: number;
  10965. /**
  10966. * Define if the animation should loop or stop after the first play.
  10967. */
  10968. loop?: boolean;
  10969. private _target;
  10970. /**
  10971. * Instantiate the action
  10972. * @param triggerOptions defines the trigger options
  10973. * @param target defines the target animation or animation name
  10974. * @param from defines from where the animation should start (animation frame)
  10975. * @param end defines where the animation should stop (animation frame)
  10976. * @param loop defines if the animation should loop or stop after the first play
  10977. * @param condition defines the trigger related conditions
  10978. */
  10979. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10980. /** @hidden */ private _prepare(): void;
  10981. /**
  10982. * Execute the action and play the animation.
  10983. */
  10984. execute(): void;
  10985. /**
  10986. * Serializes the actions and its related information.
  10987. * @param parent defines the object to serialize in
  10988. * @returns the serialized object
  10989. */
  10990. serialize(parent: any): any;
  10991. }
  10992. /**
  10993. * This defines an action responsible to stop an animation once triggered.
  10994. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10995. */
  10996. export class StopAnimationAction extends Action {
  10997. private _target;
  10998. /**
  10999. * Instantiate the action
  11000. * @param triggerOptions defines the trigger options
  11001. * @param target defines the target animation or animation name
  11002. * @param condition defines the trigger related conditions
  11003. */
  11004. constructor(triggerOptions: any, target: any, condition?: Condition);
  11005. /** @hidden */ private _prepare(): void;
  11006. /**
  11007. * Execute the action and stop the animation.
  11008. */
  11009. execute(): void;
  11010. /**
  11011. * Serializes the actions and its related information.
  11012. * @param parent defines the object to serialize in
  11013. * @returns the serialized object
  11014. */
  11015. serialize(parent: any): any;
  11016. }
  11017. /**
  11018. * This defines an action responsible that does nothing once triggered.
  11019. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11020. */
  11021. export class DoNothingAction extends Action {
  11022. /**
  11023. * Instantiate the action
  11024. * @param triggerOptions defines the trigger options
  11025. * @param condition defines the trigger related conditions
  11026. */
  11027. constructor(triggerOptions?: any, condition?: Condition);
  11028. /**
  11029. * Execute the action and do nothing.
  11030. */
  11031. execute(): void;
  11032. /**
  11033. * Serializes the actions and its related information.
  11034. * @param parent defines the object to serialize in
  11035. * @returns the serialized object
  11036. */
  11037. serialize(parent: any): any;
  11038. }
  11039. /**
  11040. * This defines an action responsible to trigger several actions once triggered.
  11041. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11042. */
  11043. export class CombineAction extends Action {
  11044. /**
  11045. * The list of aggregated animations to run.
  11046. */
  11047. children: Action[];
  11048. /**
  11049. * Instantiate the action
  11050. * @param triggerOptions defines the trigger options
  11051. * @param children defines the list of aggregated animations to run
  11052. * @param condition defines the trigger related conditions
  11053. */
  11054. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11055. /** @hidden */ private _prepare(): void;
  11056. /**
  11057. * Execute the action and executes all the aggregated actions.
  11058. */
  11059. execute(evt: ActionEvent): void;
  11060. /**
  11061. * Serializes the actions and its related information.
  11062. * @param parent defines the object to serialize in
  11063. * @returns the serialized object
  11064. */
  11065. serialize(parent: any): any;
  11066. }
  11067. /**
  11068. * This defines an action responsible to run code (external event) once triggered.
  11069. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11070. */
  11071. export class ExecuteCodeAction extends Action {
  11072. /**
  11073. * The callback function to run.
  11074. */
  11075. func: (evt: ActionEvent) => void;
  11076. /**
  11077. * Instantiate the action
  11078. * @param triggerOptions defines the trigger options
  11079. * @param func defines the callback function to run
  11080. * @param condition defines the trigger related conditions
  11081. */
  11082. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11083. /**
  11084. * Execute the action and run the attached code.
  11085. */
  11086. execute(evt: ActionEvent): void;
  11087. }
  11088. /**
  11089. * This defines an action responsible to set the parent property of the target once triggered.
  11090. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11091. */
  11092. export class SetParentAction extends Action {
  11093. private _parent;
  11094. private _target;
  11095. /**
  11096. * Instantiate the action
  11097. * @param triggerOptions defines the trigger options
  11098. * @param target defines the target containing the parent property
  11099. * @param parent defines from where the animation should start (animation frame)
  11100. * @param condition defines the trigger related conditions
  11101. */
  11102. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11103. /** @hidden */ private _prepare(): void;
  11104. /**
  11105. * Execute the action and set the parent property.
  11106. */
  11107. execute(): void;
  11108. /**
  11109. * Serializes the actions and its related information.
  11110. * @param parent defines the object to serialize in
  11111. * @returns the serialized object
  11112. */
  11113. serialize(parent: any): any;
  11114. }
  11115. }
  11116. declare module BABYLON {
  11117. /**
  11118. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11119. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11120. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11121. */
  11122. export class ActionManager extends AbstractActionManager {
  11123. /**
  11124. * Nothing
  11125. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11126. */
  11127. static readonly NothingTrigger: number;
  11128. /**
  11129. * On pick
  11130. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11131. */
  11132. static readonly OnPickTrigger: number;
  11133. /**
  11134. * On left pick
  11135. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11136. */
  11137. static readonly OnLeftPickTrigger: number;
  11138. /**
  11139. * On right pick
  11140. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11141. */
  11142. static readonly OnRightPickTrigger: number;
  11143. /**
  11144. * On center pick
  11145. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11146. */
  11147. static readonly OnCenterPickTrigger: number;
  11148. /**
  11149. * On pick down
  11150. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11151. */
  11152. static readonly OnPickDownTrigger: number;
  11153. /**
  11154. * On double pick
  11155. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11156. */
  11157. static readonly OnDoublePickTrigger: number;
  11158. /**
  11159. * On pick up
  11160. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11161. */
  11162. static readonly OnPickUpTrigger: number;
  11163. /**
  11164. * On pick out.
  11165. * This trigger will only be raised if you also declared a OnPickDown
  11166. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11167. */
  11168. static readonly OnPickOutTrigger: number;
  11169. /**
  11170. * On long press
  11171. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11172. */
  11173. static readonly OnLongPressTrigger: number;
  11174. /**
  11175. * On pointer over
  11176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11177. */
  11178. static readonly OnPointerOverTrigger: number;
  11179. /**
  11180. * On pointer out
  11181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11182. */
  11183. static readonly OnPointerOutTrigger: number;
  11184. /**
  11185. * On every frame
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11187. */
  11188. static readonly OnEveryFrameTrigger: number;
  11189. /**
  11190. * On intersection enter
  11191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11192. */
  11193. static readonly OnIntersectionEnterTrigger: number;
  11194. /**
  11195. * On intersection exit
  11196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11197. */
  11198. static readonly OnIntersectionExitTrigger: number;
  11199. /**
  11200. * On key down
  11201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11202. */
  11203. static readonly OnKeyDownTrigger: number;
  11204. /**
  11205. * On key up
  11206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11207. */
  11208. static readonly OnKeyUpTrigger: number;
  11209. private _scene;
  11210. /**
  11211. * Creates a new action manager
  11212. * @param scene defines the hosting scene
  11213. */
  11214. constructor(scene: Scene);
  11215. /**
  11216. * Releases all associated resources
  11217. */
  11218. dispose(): void;
  11219. /**
  11220. * Gets hosting scene
  11221. * @returns the hosting scene
  11222. */
  11223. getScene(): Scene;
  11224. /**
  11225. * Does this action manager handles actions of any of the given triggers
  11226. * @param triggers defines the triggers to be tested
  11227. * @return a boolean indicating whether one (or more) of the triggers is handled
  11228. */
  11229. hasSpecificTriggers(triggers: number[]): boolean;
  11230. /**
  11231. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11232. * speed.
  11233. * @param triggerA defines the trigger to be tested
  11234. * @param triggerB defines the trigger to be tested
  11235. * @return a boolean indicating whether one (or more) of the triggers is handled
  11236. */
  11237. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11238. /**
  11239. * Does this action manager handles actions of a given trigger
  11240. * @param trigger defines the trigger to be tested
  11241. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11242. * @return whether the trigger is handled
  11243. */
  11244. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11245. /**
  11246. * Does this action manager has pointer triggers
  11247. */
  11248. readonly hasPointerTriggers: boolean;
  11249. /**
  11250. * Does this action manager has pick triggers
  11251. */
  11252. readonly hasPickTriggers: boolean;
  11253. /**
  11254. * Registers an action to this action manager
  11255. * @param action defines the action to be registered
  11256. * @return the action amended (prepared) after registration
  11257. */
  11258. registerAction(action: IAction): Nullable<IAction>;
  11259. /**
  11260. * Unregisters an action to this action manager
  11261. * @param action defines the action to be unregistered
  11262. * @return a boolean indicating whether the action has been unregistered
  11263. */
  11264. unregisterAction(action: IAction): Boolean;
  11265. /**
  11266. * Process a specific trigger
  11267. * @param trigger defines the trigger to process
  11268. * @param evt defines the event details to be processed
  11269. */
  11270. processTrigger(trigger: number, evt?: IActionEvent): void;
  11271. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  11272. /** @hidden */ private _getProperty(propertyPath: string): string;
  11273. /**
  11274. * Serialize this manager to a JSON object
  11275. * @param name defines the property name to store this manager
  11276. * @returns a JSON representation of this manager
  11277. */
  11278. serialize(name: string): any;
  11279. /**
  11280. * Creates a new ActionManager from a JSON data
  11281. * @param parsedActions defines the JSON data to read from
  11282. * @param object defines the hosting mesh
  11283. * @param scene defines the hosting scene
  11284. */
  11285. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11286. /**
  11287. * Get a trigger name by index
  11288. * @param trigger defines the trigger index
  11289. * @returns a trigger name
  11290. */
  11291. static GetTriggerName(trigger: number): string;
  11292. }
  11293. }
  11294. declare module BABYLON {
  11295. /**
  11296. * Class representing a ray with position and direction
  11297. */
  11298. export class Ray {
  11299. /** origin point */
  11300. origin: Vector3;
  11301. /** direction */
  11302. direction: Vector3;
  11303. /** length of the ray */
  11304. length: number;
  11305. private static readonly TmpVector3;
  11306. private _tmpRay;
  11307. /**
  11308. * Creates a new ray
  11309. * @param origin origin point
  11310. * @param direction direction
  11311. * @param length length of the ray
  11312. */
  11313. constructor(
  11314. /** origin point */
  11315. origin: Vector3,
  11316. /** direction */
  11317. direction: Vector3,
  11318. /** length of the ray */
  11319. length?: number);
  11320. /**
  11321. * Checks if the ray intersects a box
  11322. * @param minimum bound of the box
  11323. * @param maximum bound of the box
  11324. * @param intersectionTreshold extra extend to be added to the box in all direction
  11325. * @returns if the box was hit
  11326. */
  11327. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11328. /**
  11329. * Checks if the ray intersects a box
  11330. * @param box the bounding box to check
  11331. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11332. * @returns if the box was hit
  11333. */
  11334. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11335. /**
  11336. * If the ray hits a sphere
  11337. * @param sphere the bounding sphere to check
  11338. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11339. * @returns true if it hits the sphere
  11340. */
  11341. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11342. /**
  11343. * If the ray hits a triange
  11344. * @param vertex0 triangle vertex
  11345. * @param vertex1 triangle vertex
  11346. * @param vertex2 triangle vertex
  11347. * @returns intersection information if hit
  11348. */
  11349. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11350. /**
  11351. * Checks if ray intersects a plane
  11352. * @param plane the plane to check
  11353. * @returns the distance away it was hit
  11354. */
  11355. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11356. /**
  11357. * Checks if ray intersects a mesh
  11358. * @param mesh the mesh to check
  11359. * @param fastCheck if only the bounding box should checked
  11360. * @returns picking info of the intersecton
  11361. */
  11362. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11363. /**
  11364. * Checks if ray intersects a mesh
  11365. * @param meshes the meshes to check
  11366. * @param fastCheck if only the bounding box should checked
  11367. * @param results array to store result in
  11368. * @returns Array of picking infos
  11369. */
  11370. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11371. private _comparePickingInfo;
  11372. private static smallnum;
  11373. private static rayl;
  11374. /**
  11375. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11376. * @param sega the first point of the segment to test the intersection against
  11377. * @param segb the second point of the segment to test the intersection against
  11378. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11379. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11380. */
  11381. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11382. /**
  11383. * Update the ray from viewport position
  11384. * @param x position
  11385. * @param y y position
  11386. * @param viewportWidth viewport width
  11387. * @param viewportHeight viewport height
  11388. * @param world world matrix
  11389. * @param view view matrix
  11390. * @param projection projection matrix
  11391. * @returns this ray updated
  11392. */
  11393. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11394. /**
  11395. * Creates a ray with origin and direction of 0,0,0
  11396. * @returns the new ray
  11397. */
  11398. static Zero(): Ray;
  11399. /**
  11400. * Creates a new ray from screen space and viewport
  11401. * @param x position
  11402. * @param y y position
  11403. * @param viewportWidth viewport width
  11404. * @param viewportHeight viewport height
  11405. * @param world world matrix
  11406. * @param view view matrix
  11407. * @param projection projection matrix
  11408. * @returns new ray
  11409. */
  11410. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11411. /**
  11412. * 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
  11413. * transformed to the given world matrix.
  11414. * @param origin The origin point
  11415. * @param end The end point
  11416. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11417. * @returns the new ray
  11418. */
  11419. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11420. /**
  11421. * Transforms a ray by a matrix
  11422. * @param ray ray to transform
  11423. * @param matrix matrix to apply
  11424. * @returns the resulting new ray
  11425. */
  11426. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11427. /**
  11428. * Transforms a ray by a matrix
  11429. * @param ray ray to transform
  11430. * @param matrix matrix to apply
  11431. * @param result ray to store result in
  11432. */
  11433. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11434. /**
  11435. * Unproject a ray from screen space to object space
  11436. * @param sourceX defines the screen space x coordinate to use
  11437. * @param sourceY defines the screen space y coordinate to use
  11438. * @param viewportWidth defines the current width of the viewport
  11439. * @param viewportHeight defines the current height of the viewport
  11440. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11441. * @param view defines the view matrix to use
  11442. * @param projection defines the projection matrix to use
  11443. */
  11444. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11445. }
  11446. /**
  11447. * Type used to define predicate used to select faces when a mesh intersection is detected
  11448. */
  11449. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11450. interface Scene {
  11451. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  11452. /** @hidden */ private _cachedRayForTransform: Ray;
  11453. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  11454. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11455. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11456. }
  11457. }
  11458. declare module BABYLON {
  11459. /**
  11460. * Groups all the scene component constants in one place to ease maintenance.
  11461. * @hidden
  11462. */
  11463. export class SceneComponentConstants {
  11464. static readonly NAME_EFFECTLAYER: string;
  11465. static readonly NAME_LAYER: string;
  11466. static readonly NAME_LENSFLARESYSTEM: string;
  11467. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11468. static readonly NAME_PARTICLESYSTEM: string;
  11469. static readonly NAME_GAMEPAD: string;
  11470. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11471. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11472. static readonly NAME_DEPTHRENDERER: string;
  11473. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11474. static readonly NAME_SPRITE: string;
  11475. static readonly NAME_OUTLINERENDERER: string;
  11476. static readonly NAME_PROCEDURALTEXTURE: string;
  11477. static readonly NAME_SHADOWGENERATOR: string;
  11478. static readonly NAME_OCTREE: string;
  11479. static readonly NAME_PHYSICSENGINE: string;
  11480. static readonly NAME_AUDIO: string;
  11481. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11482. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11483. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11484. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11485. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11486. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11487. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11488. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11489. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11490. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11491. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11492. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11493. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11494. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11495. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11496. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11497. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11498. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11499. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11500. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11501. static readonly STEP_AFTERRENDER_AUDIO: number;
  11502. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11503. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11504. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11505. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11506. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11507. static readonly STEP_POINTERMOVE_SPRITE: number;
  11508. static readonly STEP_POINTERDOWN_SPRITE: number;
  11509. static readonly STEP_POINTERUP_SPRITE: number;
  11510. }
  11511. /**
  11512. * This represents a scene component.
  11513. *
  11514. * This is used to decouple the dependency the scene is having on the different workloads like
  11515. * layers, post processes...
  11516. */
  11517. export interface ISceneComponent {
  11518. /**
  11519. * The name of the component. Each component must have a unique name.
  11520. */
  11521. name: string;
  11522. /**
  11523. * The scene the component belongs to.
  11524. */
  11525. scene: Scene;
  11526. /**
  11527. * Register the component to one instance of a scene.
  11528. */
  11529. register(): void;
  11530. /**
  11531. * Rebuilds the elements related to this component in case of
  11532. * context lost for instance.
  11533. */
  11534. rebuild(): void;
  11535. /**
  11536. * Disposes the component and the associated ressources.
  11537. */
  11538. dispose(): void;
  11539. }
  11540. /**
  11541. * This represents a SERIALIZABLE scene component.
  11542. *
  11543. * This extends Scene Component to add Serialization methods on top.
  11544. */
  11545. export interface ISceneSerializableComponent extends ISceneComponent {
  11546. /**
  11547. * Adds all the elements from the container to the scene
  11548. * @param container the container holding the elements
  11549. */
  11550. addFromContainer(container: AbstractScene): void;
  11551. /**
  11552. * Removes all the elements in the container from the scene
  11553. * @param container contains the elements to remove
  11554. * @param dispose if the removed element should be disposed (default: false)
  11555. */
  11556. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11557. /**
  11558. * Serializes the component data to the specified json object
  11559. * @param serializationObject The object to serialize to
  11560. */
  11561. serialize(serializationObject: any): void;
  11562. }
  11563. /**
  11564. * Strong typing of a Mesh related stage step action
  11565. */
  11566. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11567. /**
  11568. * Strong typing of a Evaluate Sub Mesh related stage step action
  11569. */
  11570. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11571. /**
  11572. * Strong typing of a Active Mesh related stage step action
  11573. */
  11574. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11575. /**
  11576. * Strong typing of a Camera related stage step action
  11577. */
  11578. export type CameraStageAction = (camera: Camera) => void;
  11579. /**
  11580. * Strong typing of a Camera Frame buffer related stage step action
  11581. */
  11582. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11583. /**
  11584. * Strong typing of a Render Target related stage step action
  11585. */
  11586. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11587. /**
  11588. * Strong typing of a RenderingGroup related stage step action
  11589. */
  11590. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11591. /**
  11592. * Strong typing of a Mesh Render related stage step action
  11593. */
  11594. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11595. /**
  11596. * Strong typing of a simple stage step action
  11597. */
  11598. export type SimpleStageAction = () => void;
  11599. /**
  11600. * Strong typing of a render target action.
  11601. */
  11602. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11603. /**
  11604. * Strong typing of a pointer move action.
  11605. */
  11606. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11607. /**
  11608. * Strong typing of a pointer up/down action.
  11609. */
  11610. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11611. /**
  11612. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11613. * @hidden
  11614. */
  11615. export class Stage<T extends Function> extends Array<{
  11616. index: number;
  11617. component: ISceneComponent;
  11618. action: T;
  11619. }> {
  11620. /**
  11621. * Hide ctor from the rest of the world.
  11622. * @param items The items to add.
  11623. */
  11624. private constructor();
  11625. /**
  11626. * Creates a new Stage.
  11627. * @returns A new instance of a Stage
  11628. */
  11629. static Create<T extends Function>(): Stage<T>;
  11630. /**
  11631. * Registers a step in an ordered way in the targeted stage.
  11632. * @param index Defines the position to register the step in
  11633. * @param component Defines the component attached to the step
  11634. * @param action Defines the action to launch during the step
  11635. */
  11636. registerStep(index: number, component: ISceneComponent, action: T): void;
  11637. /**
  11638. * Clears all the steps from the stage.
  11639. */
  11640. clear(): void;
  11641. }
  11642. }
  11643. declare module BABYLON {
  11644. interface Scene {
  11645. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11646. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11647. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11648. /**
  11649. * All of the sprite managers added to this scene
  11650. * @see http://doc.babylonjs.com/babylon101/sprites
  11651. */
  11652. spriteManagers: Array<ISpriteManager>;
  11653. /**
  11654. * An event triggered when sprites rendering is about to start
  11655. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11656. */
  11657. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11658. /**
  11659. * An event triggered when sprites rendering is done
  11660. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11661. */
  11662. onAfterSpritesRenderingObservable: Observable<Scene>;
  11663. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11664. /** Launch a ray to try to pick a sprite in the scene
  11665. * @param x position on screen
  11666. * @param y position on screen
  11667. * @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
  11668. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11669. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11670. * @returns a PickingInfo
  11671. */
  11672. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11673. /** Use the given ray to pick a sprite in the scene
  11674. * @param ray The ray (in world space) to use to pick meshes
  11675. * @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
  11676. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11677. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11678. * @returns a PickingInfo
  11679. */
  11680. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11681. /**
  11682. * Force the sprite under the pointer
  11683. * @param sprite defines the sprite to use
  11684. */
  11685. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11686. /**
  11687. * Gets the sprite under the pointer
  11688. * @returns a Sprite or null if no sprite is under the pointer
  11689. */
  11690. getPointerOverSprite(): Nullable<Sprite>;
  11691. }
  11692. /**
  11693. * Defines the sprite scene component responsible to manage sprites
  11694. * in a given scene.
  11695. */
  11696. export class SpriteSceneComponent implements ISceneComponent {
  11697. /**
  11698. * The component name helpfull to identify the component in the list of scene components.
  11699. */
  11700. readonly name: string;
  11701. /**
  11702. * The scene the component belongs to.
  11703. */
  11704. scene: Scene;
  11705. /** @hidden */
  11706. private _spritePredicate;
  11707. /**
  11708. * Creates a new instance of the component for the given scene
  11709. * @param scene Defines the scene to register the component in
  11710. */
  11711. constructor(scene: Scene);
  11712. /**
  11713. * Registers the component in a given scene
  11714. */
  11715. register(): void;
  11716. /**
  11717. * Rebuilds the elements related to this component in case of
  11718. * context lost for instance.
  11719. */
  11720. rebuild(): void;
  11721. /**
  11722. * Disposes the component and the associated ressources.
  11723. */
  11724. dispose(): void;
  11725. private _pickSpriteButKeepRay;
  11726. private _pointerMove;
  11727. private _pointerDown;
  11728. private _pointerUp;
  11729. }
  11730. }
  11731. declare module BABYLON {
  11732. /** @hidden */
  11733. export var fogFragmentDeclaration: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module BABYLON {
  11739. /** @hidden */
  11740. export var fogFragment: {
  11741. name: string;
  11742. shader: string;
  11743. };
  11744. }
  11745. declare module BABYLON {
  11746. /** @hidden */
  11747. export var spritesPixelShader: {
  11748. name: string;
  11749. shader: string;
  11750. };
  11751. }
  11752. declare module BABYLON {
  11753. /** @hidden */
  11754. export var fogVertexDeclaration: {
  11755. name: string;
  11756. shader: string;
  11757. };
  11758. }
  11759. declare module BABYLON {
  11760. /** @hidden */
  11761. export var spritesVertexShader: {
  11762. name: string;
  11763. shader: string;
  11764. };
  11765. }
  11766. declare module BABYLON {
  11767. /**
  11768. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11769. */
  11770. export interface ISpriteManager extends IDisposable {
  11771. /**
  11772. * Restricts the camera to viewing objects with the same layerMask.
  11773. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11774. */
  11775. layerMask: number;
  11776. /**
  11777. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11778. */
  11779. isPickable: boolean;
  11780. /**
  11781. * Specifies the rendering group id for this mesh (0 by default)
  11782. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11783. */
  11784. renderingGroupId: number;
  11785. /**
  11786. * Defines the list of sprites managed by the manager.
  11787. */
  11788. sprites: Array<Sprite>;
  11789. /**
  11790. * Tests the intersection of a sprite with a specific ray.
  11791. * @param ray The ray we are sending to test the collision
  11792. * @param camera The camera space we are sending rays in
  11793. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11794. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11795. * @returns picking info or null.
  11796. */
  11797. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11798. /**
  11799. * Renders the list of sprites on screen.
  11800. */
  11801. render(): void;
  11802. }
  11803. /**
  11804. * Class used to manage multiple sprites on the same spritesheet
  11805. * @see http://doc.babylonjs.com/babylon101/sprites
  11806. */
  11807. export class SpriteManager implements ISpriteManager {
  11808. /** defines the manager's name */
  11809. name: string;
  11810. /** Gets the list of sprites */
  11811. sprites: Sprite[];
  11812. /** Gets or sets the rendering group id (0 by default) */
  11813. renderingGroupId: number;
  11814. /** Gets or sets camera layer mask */
  11815. layerMask: number;
  11816. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11817. fogEnabled: boolean;
  11818. /** Gets or sets a boolean indicating if the sprites are pickable */
  11819. isPickable: boolean;
  11820. /** Defines the default width of a cell in the spritesheet */
  11821. cellWidth: number;
  11822. /** Defines the default height of a cell in the spritesheet */
  11823. cellHeight: number;
  11824. /**
  11825. * An event triggered when the manager is disposed.
  11826. */
  11827. onDisposeObservable: Observable<SpriteManager>;
  11828. private _onDisposeObserver;
  11829. /**
  11830. * Callback called when the manager is disposed
  11831. */
  11832. onDispose: () => void;
  11833. private _capacity;
  11834. private _spriteTexture;
  11835. private _epsilon;
  11836. private _scene;
  11837. private _vertexData;
  11838. private _buffer;
  11839. private _vertexBuffers;
  11840. private _indexBuffer;
  11841. private _effectBase;
  11842. private _effectFog;
  11843. /**
  11844. * Gets or sets the spritesheet texture
  11845. */
  11846. texture: Texture;
  11847. /**
  11848. * Creates a new sprite manager
  11849. * @param name defines the manager's name
  11850. * @param imgUrl defines the sprite sheet url
  11851. * @param capacity defines the maximum allowed number of sprites
  11852. * @param cellSize defines the size of a sprite cell
  11853. * @param scene defines the hosting scene
  11854. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11855. * @param samplingMode defines the smapling mode to use with spritesheet
  11856. */
  11857. constructor(
  11858. /** defines the manager's name */
  11859. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11860. private _appendSpriteVertex;
  11861. /**
  11862. * Intersects the sprites with a ray
  11863. * @param ray defines the ray to intersect with
  11864. * @param camera defines the current active camera
  11865. * @param predicate defines a predicate used to select candidate sprites
  11866. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11867. * @returns null if no hit or a PickingInfo
  11868. */
  11869. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11870. /**
  11871. * Render all child sprites
  11872. */
  11873. render(): void;
  11874. /**
  11875. * Release associated resources
  11876. */
  11877. dispose(): void;
  11878. }
  11879. }
  11880. declare module BABYLON {
  11881. /**
  11882. * Class used to represent a sprite
  11883. * @see http://doc.babylonjs.com/babylon101/sprites
  11884. */
  11885. export class Sprite {
  11886. /** defines the name */
  11887. name: string;
  11888. /** Gets or sets the current world position */
  11889. position: Vector3;
  11890. /** Gets or sets the main color */
  11891. color: Color4;
  11892. /** Gets or sets the width */
  11893. width: number;
  11894. /** Gets or sets the height */
  11895. height: number;
  11896. /** Gets or sets rotation angle */
  11897. angle: number;
  11898. /** Gets or sets the cell index in the sprite sheet */
  11899. cellIndex: number;
  11900. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11901. invertU: number;
  11902. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11903. invertV: number;
  11904. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11905. disposeWhenFinishedAnimating: boolean;
  11906. /** Gets the list of attached animations */
  11907. animations: Animation[];
  11908. /** Gets or sets a boolean indicating if the sprite can be picked */
  11909. isPickable: boolean;
  11910. /**
  11911. * Gets or sets the associated action manager
  11912. */
  11913. actionManager: Nullable<ActionManager>;
  11914. private _animationStarted;
  11915. private _loopAnimation;
  11916. private _fromIndex;
  11917. private _toIndex;
  11918. private _delay;
  11919. private _direction;
  11920. private _manager;
  11921. private _time;
  11922. private _onAnimationEnd;
  11923. /**
  11924. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11925. */
  11926. isVisible: boolean;
  11927. /**
  11928. * Gets or sets the sprite size
  11929. */
  11930. size: number;
  11931. /**
  11932. * Creates a new Sprite
  11933. * @param name defines the name
  11934. * @param manager defines the manager
  11935. */
  11936. constructor(
  11937. /** defines the name */
  11938. name: string, manager: ISpriteManager);
  11939. /**
  11940. * Starts an animation
  11941. * @param from defines the initial key
  11942. * @param to defines the end key
  11943. * @param loop defines if the animation must loop
  11944. * @param delay defines the start delay (in ms)
  11945. * @param onAnimationEnd defines a callback to call when animation ends
  11946. */
  11947. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11948. /** Stops current animation (if any) */
  11949. stopAnimation(): void;
  11950. /** @hidden */ private _animate(deltaTime: number): void;
  11951. /** Release associated resources */
  11952. dispose(): void;
  11953. }
  11954. }
  11955. declare module BABYLON {
  11956. /**
  11957. * Information about the result of picking within a scene
  11958. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11959. */
  11960. export class PickingInfo {
  11961. /** @hidden */ private _pickingUnavailable: boolean;
  11962. /**
  11963. * If the pick collided with an object
  11964. */
  11965. hit: boolean;
  11966. /**
  11967. * Distance away where the pick collided
  11968. */
  11969. distance: number;
  11970. /**
  11971. * The location of pick collision
  11972. */
  11973. pickedPoint: Nullable<Vector3>;
  11974. /**
  11975. * The mesh corresponding the the pick collision
  11976. */
  11977. pickedMesh: Nullable<AbstractMesh>;
  11978. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  11979. bu: number;
  11980. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  11981. bv: number;
  11982. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11983. faceId: number;
  11984. /** Id of the the submesh that was picked */
  11985. subMeshId: number;
  11986. /** If a sprite was picked, this will be the sprite the pick collided with */
  11987. pickedSprite: Nullable<Sprite>;
  11988. /**
  11989. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11990. */
  11991. originMesh: Nullable<AbstractMesh>;
  11992. /**
  11993. * The ray that was used to perform the picking.
  11994. */
  11995. ray: Nullable<Ray>;
  11996. /**
  11997. * Gets the normal correspodning to the face the pick collided with
  11998. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11999. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12000. * @returns The normal correspodning to the face the pick collided with
  12001. */
  12002. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12003. /**
  12004. * Gets the texture coordinates of where the pick occured
  12005. * @returns the vector containing the coordnates of the texture
  12006. */
  12007. getTextureCoordinates(): Nullable<Vector2>;
  12008. }
  12009. }
  12010. declare module BABYLON {
  12011. /**
  12012. * Gather the list of pointer event types as constants.
  12013. */
  12014. export class PointerEventTypes {
  12015. /**
  12016. * 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.
  12017. */
  12018. static readonly POINTERDOWN: number;
  12019. /**
  12020. * The pointerup event is fired when a pointer is no longer active.
  12021. */
  12022. static readonly POINTERUP: number;
  12023. /**
  12024. * The pointermove event is fired when a pointer changes coordinates.
  12025. */
  12026. static readonly POINTERMOVE: number;
  12027. /**
  12028. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12029. */
  12030. static readonly POINTERWHEEL: number;
  12031. /**
  12032. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12033. */
  12034. static readonly POINTERPICK: number;
  12035. /**
  12036. * The pointertap event is fired when a the object has been touched and released without drag.
  12037. */
  12038. static readonly POINTERTAP: number;
  12039. /**
  12040. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12041. */
  12042. static readonly POINTERDOUBLETAP: number;
  12043. }
  12044. /**
  12045. * Base class of pointer info types.
  12046. */
  12047. export class PointerInfoBase {
  12048. /**
  12049. * Defines the type of event (PointerEventTypes)
  12050. */
  12051. type: number;
  12052. /**
  12053. * Defines the related dom event
  12054. */
  12055. event: PointerEvent | MouseWheelEvent;
  12056. /**
  12057. * Instantiates the base class of pointers info.
  12058. * @param type Defines the type of event (PointerEventTypes)
  12059. * @param event Defines the related dom event
  12060. */
  12061. constructor(
  12062. /**
  12063. * Defines the type of event (PointerEventTypes)
  12064. */
  12065. type: number,
  12066. /**
  12067. * Defines the related dom event
  12068. */
  12069. event: PointerEvent | MouseWheelEvent);
  12070. }
  12071. /**
  12072. * This class is used to store pointer related info for the onPrePointerObservable event.
  12073. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12074. */
  12075. export class PointerInfoPre extends PointerInfoBase {
  12076. /**
  12077. * Ray from a pointer if availible (eg. 6dof controller)
  12078. */
  12079. ray: Nullable<Ray>;
  12080. /**
  12081. * Defines the local position of the pointer on the canvas.
  12082. */
  12083. localPosition: Vector2;
  12084. /**
  12085. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12086. */
  12087. skipOnPointerObservable: boolean;
  12088. /**
  12089. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12090. * @param type Defines the type of event (PointerEventTypes)
  12091. * @param event Defines the related dom event
  12092. * @param localX Defines the local x coordinates of the pointer when the event occured
  12093. * @param localY Defines the local y coordinates of the pointer when the event occured
  12094. */
  12095. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12096. }
  12097. /**
  12098. * This type contains all the data related to a pointer event in Babylon.js.
  12099. * 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.
  12100. */
  12101. export class PointerInfo extends PointerInfoBase {
  12102. /**
  12103. * Defines the picking info associated to the info (if any)\
  12104. */
  12105. pickInfo: Nullable<PickingInfo>;
  12106. /**
  12107. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12108. * @param type Defines the type of event (PointerEventTypes)
  12109. * @param event Defines the related dom event
  12110. * @param pickInfo Defines the picking info associated to the info (if any)\
  12111. */
  12112. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12113. /**
  12114. * Defines the picking info associated to the info (if any)\
  12115. */
  12116. pickInfo: Nullable<PickingInfo>);
  12117. }
  12118. /**
  12119. * Data relating to a touch event on the screen.
  12120. */
  12121. export interface PointerTouch {
  12122. /**
  12123. * X coordinate of touch.
  12124. */
  12125. x: number;
  12126. /**
  12127. * Y coordinate of touch.
  12128. */
  12129. y: number;
  12130. /**
  12131. * Id of touch. Unique for each finger.
  12132. */
  12133. pointerId: number;
  12134. /**
  12135. * Event type passed from DOM.
  12136. */
  12137. type: any;
  12138. }
  12139. }
  12140. declare module BABYLON {
  12141. /**
  12142. * Manage the mouse inputs to control the movement of a free camera.
  12143. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12144. */
  12145. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12146. /**
  12147. * Define if touch is enabled in the mouse input
  12148. */
  12149. touchEnabled: boolean;
  12150. /**
  12151. * Defines the camera the input is attached to.
  12152. */
  12153. camera: FreeCamera;
  12154. /**
  12155. * Defines the buttons associated with the input to handle camera move.
  12156. */
  12157. buttons: number[];
  12158. /**
  12159. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12160. */
  12161. angularSensibility: number;
  12162. private _pointerInput;
  12163. private _onMouseMove;
  12164. private _observer;
  12165. private previousPosition;
  12166. /**
  12167. * Observable for when a pointer move event occurs containing the move offset
  12168. */
  12169. onPointerMovedObservable: Observable<{
  12170. offsetX: number;
  12171. offsetY: number;
  12172. }>;
  12173. /**
  12174. * @hidden
  12175. * If the camera should be rotated automatically based on pointer movement
  12176. */ private _allowCameraRotation: boolean;
  12177. /**
  12178. * Manage the mouse inputs to control the movement of a free camera.
  12179. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12180. * @param touchEnabled Defines if touch is enabled or not
  12181. */
  12182. constructor(
  12183. /**
  12184. * Define if touch is enabled in the mouse input
  12185. */
  12186. touchEnabled?: boolean);
  12187. /**
  12188. * Attach the input controls to a specific dom element to get the input from.
  12189. * @param element Defines the element the controls should be listened from
  12190. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12191. */
  12192. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12193. /**
  12194. * Called on JS contextmenu event.
  12195. * Override this method to provide functionality.
  12196. */
  12197. protected onContextMenu(evt: PointerEvent): void;
  12198. /**
  12199. * Detach the current controls from the specified dom element.
  12200. * @param element Defines the element to stop listening the inputs from
  12201. */
  12202. detachControl(element: Nullable<HTMLElement>): void;
  12203. /**
  12204. * Gets the class name of the current intput.
  12205. * @returns the class name
  12206. */
  12207. getClassName(): string;
  12208. /**
  12209. * Get the friendly name associated with the input class.
  12210. * @returns the input friendly name
  12211. */
  12212. getSimpleName(): string;
  12213. }
  12214. }
  12215. declare module BABYLON {
  12216. /**
  12217. * Manage the touch inputs to control the movement of a free camera.
  12218. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12219. */
  12220. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12221. /**
  12222. * Defines the camera the input is attached to.
  12223. */
  12224. camera: FreeCamera;
  12225. /**
  12226. * Defines the touch sensibility for rotation.
  12227. * The higher the faster.
  12228. */
  12229. touchAngularSensibility: number;
  12230. /**
  12231. * Defines the touch sensibility for move.
  12232. * The higher the faster.
  12233. */
  12234. touchMoveSensibility: number;
  12235. private _offsetX;
  12236. private _offsetY;
  12237. private _pointerPressed;
  12238. private _pointerInput;
  12239. private _observer;
  12240. private _onLostFocus;
  12241. /**
  12242. * Attach the input controls to a specific dom element to get the input from.
  12243. * @param element Defines the element the controls should be listened from
  12244. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12245. */
  12246. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12247. /**
  12248. * Detach the current controls from the specified dom element.
  12249. * @param element Defines the element to stop listening the inputs from
  12250. */
  12251. detachControl(element: Nullable<HTMLElement>): void;
  12252. /**
  12253. * Update the current camera state depending on the inputs that have been used this frame.
  12254. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12255. */
  12256. checkInputs(): void;
  12257. /**
  12258. * Gets the class name of the current intput.
  12259. * @returns the class name
  12260. */
  12261. getClassName(): string;
  12262. /**
  12263. * Get the friendly name associated with the input class.
  12264. * @returns the input friendly name
  12265. */
  12266. getSimpleName(): string;
  12267. }
  12268. }
  12269. declare module BABYLON {
  12270. /**
  12271. * Default Inputs manager for the FreeCamera.
  12272. * It groups all the default supported inputs for ease of use.
  12273. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12274. */
  12275. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12276. /**
  12277. * @hidden
  12278. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  12279. /**
  12280. * Instantiates a new FreeCameraInputsManager.
  12281. * @param camera Defines the camera the inputs belong to
  12282. */
  12283. constructor(camera: FreeCamera);
  12284. /**
  12285. * Add keyboard input support to the input manager.
  12286. * @returns the current input manager
  12287. */
  12288. addKeyboard(): FreeCameraInputsManager;
  12289. /**
  12290. * Add mouse input support to the input manager.
  12291. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12292. * @returns the current input manager
  12293. */
  12294. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12295. /**
  12296. * Removes the mouse input support from the manager
  12297. * @returns the current input manager
  12298. */
  12299. removeMouse(): FreeCameraInputsManager;
  12300. /**
  12301. * Add touch input support to the input manager.
  12302. * @returns the current input manager
  12303. */
  12304. addTouch(): FreeCameraInputsManager;
  12305. /**
  12306. * Remove all attached input methods from a camera
  12307. */
  12308. clear(): void;
  12309. }
  12310. }
  12311. declare module BABYLON {
  12312. /**
  12313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12314. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12315. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12316. */
  12317. export class FreeCamera extends TargetCamera {
  12318. /**
  12319. * Define the collision ellipsoid of the camera.
  12320. * This is helpful to simulate a camera body like the player body around the camera
  12321. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12322. */
  12323. ellipsoid: Vector3;
  12324. /**
  12325. * Define an offset for the position of the ellipsoid around the camera.
  12326. * This can be helpful to determine the center of the body near the gravity center of the body
  12327. * instead of its head.
  12328. */
  12329. ellipsoidOffset: Vector3;
  12330. /**
  12331. * Enable or disable collisions of the camera with the rest of the scene objects.
  12332. */
  12333. checkCollisions: boolean;
  12334. /**
  12335. * Enable or disable gravity on the camera.
  12336. */
  12337. applyGravity: boolean;
  12338. /**
  12339. * Define the input manager associated to the camera.
  12340. */
  12341. inputs: FreeCameraInputsManager;
  12342. /**
  12343. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12344. * Higher values reduce sensitivity.
  12345. */
  12346. /**
  12347. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12348. * Higher values reduce sensitivity.
  12349. */
  12350. angularSensibility: number;
  12351. /**
  12352. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12353. */
  12354. keysUp: number[];
  12355. /**
  12356. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12357. */
  12358. keysDown: number[];
  12359. /**
  12360. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12361. */
  12362. keysLeft: number[];
  12363. /**
  12364. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12365. */
  12366. keysRight: number[];
  12367. /**
  12368. * Event raised when the camera collide with a mesh in the scene.
  12369. */
  12370. onCollide: (collidedMesh: AbstractMesh) => void;
  12371. private _collider;
  12372. private _needMoveForGravity;
  12373. private _oldPosition;
  12374. private _diffPosition;
  12375. private _newPosition;
  12376. /** @hidden */ private _localDirection: Vector3;
  12377. /** @hidden */ private _transformedDirection: Vector3;
  12378. /**
  12379. * Instantiates a Free Camera.
  12380. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12381. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12382. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12383. * @param name Define the name of the camera in the scene
  12384. * @param position Define the start position of the camera in the scene
  12385. * @param scene Define the scene the camera belongs to
  12386. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12387. */
  12388. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12389. /**
  12390. * Attached controls to the current camera.
  12391. * @param element Defines the element the controls should be listened from
  12392. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12393. */
  12394. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12395. /**
  12396. * Detach the current controls from the camera.
  12397. * The camera will stop reacting to inputs.
  12398. * @param element Defines the element to stop listening the inputs from
  12399. */
  12400. detachControl(element: HTMLElement): void;
  12401. private _collisionMask;
  12402. /**
  12403. * Define a collision mask to limit the list of object the camera can collide with
  12404. */
  12405. collisionMask: number;
  12406. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  12407. private _onCollisionPositionChange;
  12408. /** @hidden */ private _checkInputs(): void;
  12409. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  12410. /** @hidden */ private _updatePosition(): void;
  12411. /**
  12412. * Destroy the camera and release the current resources hold by it.
  12413. */
  12414. dispose(): void;
  12415. /**
  12416. * Gets the current object class name.
  12417. * @return the class name
  12418. */
  12419. getClassName(): string;
  12420. }
  12421. }
  12422. declare module BABYLON {
  12423. /**
  12424. * Represents a gamepad control stick position
  12425. */
  12426. export class StickValues {
  12427. /**
  12428. * The x component of the control stick
  12429. */
  12430. x: number;
  12431. /**
  12432. * The y component of the control stick
  12433. */
  12434. y: number;
  12435. /**
  12436. * Initializes the gamepad x and y control stick values
  12437. * @param x The x component of the gamepad control stick value
  12438. * @param y The y component of the gamepad control stick value
  12439. */
  12440. constructor(
  12441. /**
  12442. * The x component of the control stick
  12443. */
  12444. x: number,
  12445. /**
  12446. * The y component of the control stick
  12447. */
  12448. y: number);
  12449. }
  12450. /**
  12451. * An interface which manages callbacks for gamepad button changes
  12452. */
  12453. export interface GamepadButtonChanges {
  12454. /**
  12455. * Called when a gamepad has been changed
  12456. */
  12457. changed: boolean;
  12458. /**
  12459. * Called when a gamepad press event has been triggered
  12460. */
  12461. pressChanged: boolean;
  12462. /**
  12463. * Called when a touch event has been triggered
  12464. */
  12465. touchChanged: boolean;
  12466. /**
  12467. * Called when a value has changed
  12468. */
  12469. valueChanged: boolean;
  12470. }
  12471. /**
  12472. * Represents a gamepad
  12473. */
  12474. export class Gamepad {
  12475. /**
  12476. * The id of the gamepad
  12477. */
  12478. id: string;
  12479. /**
  12480. * The index of the gamepad
  12481. */
  12482. index: number;
  12483. /**
  12484. * The browser gamepad
  12485. */
  12486. browserGamepad: any;
  12487. /**
  12488. * Specifies what type of gamepad this represents
  12489. */
  12490. type: number;
  12491. private _leftStick;
  12492. private _rightStick;
  12493. /** @hidden */ private _isConnected: boolean;
  12494. private _leftStickAxisX;
  12495. private _leftStickAxisY;
  12496. private _rightStickAxisX;
  12497. private _rightStickAxisY;
  12498. /**
  12499. * Triggered when the left control stick has been changed
  12500. */
  12501. private _onleftstickchanged;
  12502. /**
  12503. * Triggered when the right control stick has been changed
  12504. */
  12505. private _onrightstickchanged;
  12506. /**
  12507. * Represents a gamepad controller
  12508. */
  12509. static GAMEPAD: number;
  12510. /**
  12511. * Represents a generic controller
  12512. */
  12513. static GENERIC: number;
  12514. /**
  12515. * Represents an XBox controller
  12516. */
  12517. static XBOX: number;
  12518. /**
  12519. * Represents a pose-enabled controller
  12520. */
  12521. static POSE_ENABLED: number;
  12522. /**
  12523. * Specifies whether the left control stick should be Y-inverted
  12524. */
  12525. protected _invertLeftStickY: boolean;
  12526. /**
  12527. * Specifies if the gamepad has been connected
  12528. */
  12529. readonly isConnected: boolean;
  12530. /**
  12531. * Initializes the gamepad
  12532. * @param id The id of the gamepad
  12533. * @param index The index of the gamepad
  12534. * @param browserGamepad The browser gamepad
  12535. * @param leftStickX The x component of the left joystick
  12536. * @param leftStickY The y component of the left joystick
  12537. * @param rightStickX The x component of the right joystick
  12538. * @param rightStickY The y component of the right joystick
  12539. */
  12540. constructor(
  12541. /**
  12542. * The id of the gamepad
  12543. */
  12544. id: string,
  12545. /**
  12546. * The index of the gamepad
  12547. */
  12548. index: number,
  12549. /**
  12550. * The browser gamepad
  12551. */
  12552. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12553. /**
  12554. * Callback triggered when the left joystick has changed
  12555. * @param callback
  12556. */
  12557. onleftstickchanged(callback: (values: StickValues) => void): void;
  12558. /**
  12559. * Callback triggered when the right joystick has changed
  12560. * @param callback
  12561. */
  12562. onrightstickchanged(callback: (values: StickValues) => void): void;
  12563. /**
  12564. * Gets the left joystick
  12565. */
  12566. /**
  12567. * Sets the left joystick values
  12568. */
  12569. leftStick: StickValues;
  12570. /**
  12571. * Gets the right joystick
  12572. */
  12573. /**
  12574. * Sets the right joystick value
  12575. */
  12576. rightStick: StickValues;
  12577. /**
  12578. * Updates the gamepad joystick positions
  12579. */
  12580. update(): void;
  12581. /**
  12582. * Disposes the gamepad
  12583. */
  12584. dispose(): void;
  12585. }
  12586. /**
  12587. * Represents a generic gamepad
  12588. */
  12589. export class GenericPad extends Gamepad {
  12590. private _buttons;
  12591. private _onbuttondown;
  12592. private _onbuttonup;
  12593. /**
  12594. * Observable triggered when a button has been pressed
  12595. */
  12596. onButtonDownObservable: Observable<number>;
  12597. /**
  12598. * Observable triggered when a button has been released
  12599. */
  12600. onButtonUpObservable: Observable<number>;
  12601. /**
  12602. * Callback triggered when a button has been pressed
  12603. * @param callback Called when a button has been pressed
  12604. */
  12605. onbuttondown(callback: (buttonPressed: number) => void): void;
  12606. /**
  12607. * Callback triggered when a button has been released
  12608. * @param callback Called when a button has been released
  12609. */
  12610. onbuttonup(callback: (buttonReleased: number) => void): void;
  12611. /**
  12612. * Initializes the generic gamepad
  12613. * @param id The id of the generic gamepad
  12614. * @param index The index of the generic gamepad
  12615. * @param browserGamepad The browser gamepad
  12616. */
  12617. constructor(id: string, index: number, browserGamepad: any);
  12618. private _setButtonValue;
  12619. /**
  12620. * Updates the generic gamepad
  12621. */
  12622. update(): void;
  12623. /**
  12624. * Disposes the generic gamepad
  12625. */
  12626. dispose(): void;
  12627. }
  12628. }
  12629. declare module BABYLON {
  12630. /**
  12631. * Defines the types of pose enabled controllers that are supported
  12632. */
  12633. export enum PoseEnabledControllerType {
  12634. /**
  12635. * HTC Vive
  12636. */
  12637. VIVE = 0,
  12638. /**
  12639. * Oculus Rift
  12640. */
  12641. OCULUS = 1,
  12642. /**
  12643. * Windows mixed reality
  12644. */
  12645. WINDOWS = 2,
  12646. /**
  12647. * Samsung gear VR
  12648. */
  12649. GEAR_VR = 3,
  12650. /**
  12651. * Google Daydream
  12652. */
  12653. DAYDREAM = 4,
  12654. /**
  12655. * Generic
  12656. */
  12657. GENERIC = 5
  12658. }
  12659. /**
  12660. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12661. */
  12662. export interface MutableGamepadButton {
  12663. /**
  12664. * Value of the button/trigger
  12665. */
  12666. value: number;
  12667. /**
  12668. * If the button/trigger is currently touched
  12669. */
  12670. touched: boolean;
  12671. /**
  12672. * If the button/trigger is currently pressed
  12673. */
  12674. pressed: boolean;
  12675. }
  12676. /**
  12677. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12678. * @hidden
  12679. */
  12680. export interface ExtendedGamepadButton extends GamepadButton {
  12681. /**
  12682. * If the button/trigger is currently pressed
  12683. */
  12684. readonly pressed: boolean;
  12685. /**
  12686. * If the button/trigger is currently touched
  12687. */
  12688. readonly touched: boolean;
  12689. /**
  12690. * Value of the button/trigger
  12691. */
  12692. readonly value: number;
  12693. }
  12694. /** @hidden */
  12695. export interface _GamePadFactory {
  12696. /**
  12697. * Returns wether or not the current gamepad can be created for this type of controller.
  12698. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12699. * @returns true if it can be created, otherwise false
  12700. */
  12701. canCreate(gamepadInfo: any): boolean;
  12702. /**
  12703. * Creates a new instance of the Gamepad.
  12704. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12705. * @returns the new gamepad instance
  12706. */
  12707. create(gamepadInfo: any): Gamepad;
  12708. }
  12709. /**
  12710. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12711. */
  12712. export class PoseEnabledControllerHelper {
  12713. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  12714. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12715. /**
  12716. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12717. * @param vrGamepad the gamepad to initialized
  12718. * @returns a vr controller of the type the gamepad identified as
  12719. */
  12720. static InitiateController(vrGamepad: any): Gamepad;
  12721. }
  12722. /**
  12723. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12724. */
  12725. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12726. private _deviceRoomPosition;
  12727. private _deviceRoomRotationQuaternion;
  12728. /**
  12729. * The device position in babylon space
  12730. */
  12731. devicePosition: Vector3;
  12732. /**
  12733. * The device rotation in babylon space
  12734. */
  12735. deviceRotationQuaternion: Quaternion;
  12736. /**
  12737. * The scale factor of the device in babylon space
  12738. */
  12739. deviceScaleFactor: number;
  12740. /**
  12741. * (Likely devicePosition should be used instead) The device position in its room space
  12742. */
  12743. position: Vector3;
  12744. /**
  12745. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12746. */
  12747. rotationQuaternion: Quaternion;
  12748. /**
  12749. * The type of controller (Eg. Windows mixed reality)
  12750. */
  12751. controllerType: PoseEnabledControllerType;
  12752. protected _calculatedPosition: Vector3;
  12753. private _calculatedRotation;
  12754. /**
  12755. * The raw pose from the device
  12756. */
  12757. rawPose: DevicePose;
  12758. private _trackPosition;
  12759. private _maxRotationDistFromHeadset;
  12760. private _draggedRoomRotation;
  12761. /**
  12762. * @hidden
  12763. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  12764. /**
  12765. * Internal, the mesh attached to the controller
  12766. * @hidden
  12767. */ private _mesh: Nullable<AbstractMesh>;
  12768. private _poseControlledCamera;
  12769. private _leftHandSystemQuaternion;
  12770. /**
  12771. * Internal, matrix used to convert room space to babylon space
  12772. * @hidden
  12773. */ private _deviceToWorld: Matrix;
  12774. /**
  12775. * Node to be used when casting a ray from the controller
  12776. * @hidden
  12777. */ private _pointingPoseNode: Nullable<TransformNode>;
  12778. /**
  12779. * Name of the child mesh that can be used to cast a ray from the controller
  12780. */
  12781. static readonly POINTING_POSE: string;
  12782. /**
  12783. * Creates a new PoseEnabledController from a gamepad
  12784. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12785. */
  12786. constructor(browserGamepad: any);
  12787. private _workingMatrix;
  12788. /**
  12789. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12790. */
  12791. update(): void;
  12792. /**
  12793. * Updates only the pose device and mesh without doing any button event checking
  12794. */
  12795. protected _updatePoseAndMesh(): void;
  12796. /**
  12797. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12798. * @param poseData raw pose fromthe device
  12799. */
  12800. updateFromDevice(poseData: DevicePose): void;
  12801. /**
  12802. * @hidden
  12803. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  12804. /**
  12805. * Attaches a mesh to the controller
  12806. * @param mesh the mesh to be attached
  12807. */
  12808. attachToMesh(mesh: AbstractMesh): void;
  12809. /**
  12810. * Attaches the controllers mesh to a camera
  12811. * @param camera the camera the mesh should be attached to
  12812. */
  12813. attachToPoseControlledCamera(camera: TargetCamera): void;
  12814. /**
  12815. * Disposes of the controller
  12816. */
  12817. dispose(): void;
  12818. /**
  12819. * The mesh that is attached to the controller
  12820. */
  12821. readonly mesh: Nullable<AbstractMesh>;
  12822. /**
  12823. * Gets the ray of the controller in the direction the controller is pointing
  12824. * @param length the length the resulting ray should be
  12825. * @returns a ray in the direction the controller is pointing
  12826. */
  12827. getForwardRay(length?: number): Ray;
  12828. }
  12829. }
  12830. declare module BABYLON {
  12831. /**
  12832. * Defines the WebVRController object that represents controllers tracked in 3D space
  12833. */
  12834. export abstract class WebVRController extends PoseEnabledController {
  12835. /**
  12836. * Internal, the default controller model for the controller
  12837. */
  12838. protected _defaultModel: AbstractMesh;
  12839. /**
  12840. * Fired when the trigger state has changed
  12841. */
  12842. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  12843. /**
  12844. * Fired when the main button state has changed
  12845. */
  12846. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12847. /**
  12848. * Fired when the secondary button state has changed
  12849. */
  12850. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  12851. /**
  12852. * Fired when the pad state has changed
  12853. */
  12854. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  12855. /**
  12856. * Fired when controllers stick values have changed
  12857. */
  12858. onPadValuesChangedObservable: Observable<StickValues>;
  12859. /**
  12860. * Array of button availible on the controller
  12861. */
  12862. protected _buttons: Array<MutableGamepadButton>;
  12863. private _onButtonStateChange;
  12864. /**
  12865. * Fired when a controller button's state has changed
  12866. * @param callback the callback containing the button that was modified
  12867. */
  12868. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  12869. /**
  12870. * X and Y axis corrisponding to the controllers joystick
  12871. */
  12872. pad: StickValues;
  12873. /**
  12874. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  12875. */
  12876. hand: string;
  12877. /**
  12878. * The default controller model for the controller
  12879. */
  12880. readonly defaultModel: AbstractMesh;
  12881. /**
  12882. * Creates a new WebVRController from a gamepad
  12883. * @param vrGamepad the gamepad that the WebVRController should be created from
  12884. */
  12885. constructor(vrGamepad: any);
  12886. /**
  12887. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  12888. */
  12889. update(): void;
  12890. /**
  12891. * Function to be called when a button is modified
  12892. */
  12893. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  12894. /**
  12895. * Loads a mesh and attaches it to the controller
  12896. * @param scene the scene the mesh should be added to
  12897. * @param meshLoaded callback for when the mesh has been loaded
  12898. */
  12899. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  12900. private _setButtonValue;
  12901. private _changes;
  12902. private _checkChanges;
  12903. /**
  12904. * Disposes of th webVRCOntroller
  12905. */
  12906. dispose(): void;
  12907. }
  12908. }
  12909. declare module BABYLON {
  12910. /**
  12911. * The HemisphericLight simulates the ambient environment light,
  12912. * so the passed direction is the light reflection direction, not the incoming direction.
  12913. */
  12914. export class HemisphericLight extends Light {
  12915. /**
  12916. * The groundColor is the light in the opposite direction to the one specified during creation.
  12917. * 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.
  12918. */
  12919. groundColor: Color3;
  12920. /**
  12921. * The light reflection direction, not the incoming direction.
  12922. */
  12923. direction: Vector3;
  12924. /**
  12925. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  12926. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  12927. * The HemisphericLight can't cast shadows.
  12928. * Documentation : https://doc.babylonjs.com/babylon101/lights
  12929. * @param name The friendly name of the light
  12930. * @param direction The direction of the light reflection
  12931. * @param scene The scene the light belongs to
  12932. */
  12933. constructor(name: string, direction: Vector3, scene: Scene);
  12934. protected _buildUniformLayout(): void;
  12935. /**
  12936. * Returns the string "HemisphericLight".
  12937. * @return The class name
  12938. */
  12939. getClassName(): string;
  12940. /**
  12941. * Sets the HemisphericLight direction towards the passed target (Vector3).
  12942. * Returns the updated direction.
  12943. * @param target The target the direction should point to
  12944. * @return The computed direction
  12945. */
  12946. setDirectionToTarget(target: Vector3): Vector3;
  12947. /**
  12948. * Returns the shadow generator associated to the light.
  12949. * @returns Always null for hemispheric lights because it does not support shadows.
  12950. */
  12951. getShadowGenerator(): Nullable<IShadowGenerator>;
  12952. /**
  12953. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  12954. * @param effect The effect to update
  12955. * @param lightIndex The index of the light in the effect to update
  12956. * @returns The hemispheric light
  12957. */
  12958. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  12959. /**
  12960. * Computes the world matrix of the node
  12961. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  12962. * @param useWasUpdatedFlag defines a reserved property
  12963. * @returns the world matrix
  12964. */
  12965. computeWorldMatrix(): Matrix;
  12966. /**
  12967. * Returns the integer 3.
  12968. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  12969. */
  12970. getTypeID(): number;
  12971. /**
  12972. * Prepares the list of defines specific to the light type.
  12973. * @param defines the list of defines
  12974. * @param lightIndex defines the index of the light for the effect
  12975. */
  12976. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  12977. }
  12978. }
  12979. declare module BABYLON {
  12980. /** @hidden */
  12981. export var vrMultiviewToSingleviewPixelShader: {
  12982. name: string;
  12983. shader: string;
  12984. };
  12985. }
  12986. declare module BABYLON {
  12987. /**
  12988. * Renders to multiple views with a single draw call
  12989. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  12990. */
  12991. export class MultiviewRenderTarget extends RenderTargetTexture {
  12992. /**
  12993. * Creates a multiview render target
  12994. * @param scene scene used with the render target
  12995. * @param size the size of the render target (used for each view)
  12996. */
  12997. constructor(scene: Scene, size?: number | {
  12998. width: number;
  12999. height: number;
  13000. } | {
  13001. ratio: number;
  13002. });
  13003. /**
  13004. * @hidden
  13005. * @param faceIndex the face index, if its a cube texture
  13006. */ private _bindFrameBuffer(faceIndex?: number): void;
  13007. /**
  13008. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13009. * @returns the view count
  13010. */
  13011. getViewCount(): number;
  13012. }
  13013. }
  13014. declare module BABYLON {
  13015. interface Engine {
  13016. /**
  13017. * Creates a new multiview render target
  13018. * @param width defines the width of the texture
  13019. * @param height defines the height of the texture
  13020. * @returns the created multiview texture
  13021. */
  13022. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13023. /**
  13024. * Binds a multiview framebuffer to be drawn to
  13025. * @param multiviewTexture texture to bind
  13026. */
  13027. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13028. }
  13029. interface Camera {
  13030. /**
  13031. * @hidden
  13032. * 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)
  13033. */ private _useMultiviewToSingleView: boolean;
  13034. /**
  13035. * @hidden
  13036. * 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)
  13037. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  13038. /**
  13039. * @hidden
  13040. * ensures the multiview texture of the camera exists and has the specified width/height
  13041. * @param width height to set on the multiview texture
  13042. * @param height width to set on the multiview texture
  13043. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13044. }
  13045. interface Scene {
  13046. /** @hidden */ private _transformMatrixR: Matrix;
  13047. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  13048. /** @hidden */ private _createMultiviewUbo(): void;
  13049. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13050. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13056. * This will not be used for webXR as it supports displaying texture arrays directly
  13057. */
  13058. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13059. /**
  13060. * Initializes a VRMultiviewToSingleview
  13061. * @param name name of the post process
  13062. * @param camera camera to be applied to
  13063. * @param scaleFactor scaling factor to the size of the output texture
  13064. */
  13065. constructor(name: string, camera: Camera, scaleFactor: number);
  13066. }
  13067. }
  13068. declare module BABYLON {
  13069. /**
  13070. * Defines the interface used by display changed events
  13071. */
  13072. interface IDisplayChangedEventArgs {
  13073. /** Gets the vrDisplay object (if any) */
  13074. vrDisplay: Nullable<any>;
  13075. /** Gets a boolean indicating if webVR is supported */
  13076. vrSupported: boolean;
  13077. }
  13078. interface Engine {
  13079. /** @hidden */ private _vrDisplay: any;
  13080. /** @hidden */ private _vrSupported: boolean;
  13081. /** @hidden */ private _oldSize: Size;
  13082. /** @hidden */ private _oldHardwareScaleFactor: number;
  13083. /** @hidden */ private _vrExclusivePointerMode: boolean;
  13084. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13085. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  13086. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  13087. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  13088. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  13089. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  13090. /**
  13091. * Observable signaled when VR display mode changes
  13092. */
  13093. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13094. /**
  13095. * Observable signaled when VR request present is complete
  13096. */
  13097. onVRRequestPresentComplete: Observable<boolean>;
  13098. /**
  13099. * Observable signaled when VR request present starts
  13100. */
  13101. onVRRequestPresentStart: Observable<Engine>;
  13102. /**
  13103. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13104. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13105. */
  13106. isInVRExclusivePointerMode: boolean;
  13107. /**
  13108. * Gets a boolean indicating if a webVR device was detected
  13109. * @returns true if a webVR device was detected
  13110. */
  13111. isVRDevicePresent(): boolean;
  13112. /**
  13113. * Gets the current webVR device
  13114. * @returns the current webVR device (or null)
  13115. */
  13116. getVRDevice(): any;
  13117. /**
  13118. * Initializes a webVR display and starts listening to display change events
  13119. * The onVRDisplayChangedObservable will be notified upon these changes
  13120. * @returns A promise containing a VRDisplay and if vr is supported
  13121. */
  13122. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13123. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13124. /**
  13125. * Call this function to switch to webVR mode
  13126. * Will do nothing if webVR is not supported or if there is no webVR device
  13127. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13128. */
  13129. enableVR(): void;
  13130. /** @hidden */ private _onVRFullScreenTriggered(): void;
  13131. }
  13132. }
  13133. declare module BABYLON {
  13134. /**
  13135. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13136. * IMPORTANT!! The data is right-hand data.
  13137. * @export
  13138. * @interface DevicePose
  13139. */
  13140. export interface DevicePose {
  13141. /**
  13142. * The position of the device, values in array are [x,y,z].
  13143. */
  13144. readonly position: Nullable<Float32Array>;
  13145. /**
  13146. * The linearVelocity of the device, values in array are [x,y,z].
  13147. */
  13148. readonly linearVelocity: Nullable<Float32Array>;
  13149. /**
  13150. * The linearAcceleration of the device, values in array are [x,y,z].
  13151. */
  13152. readonly linearAcceleration: Nullable<Float32Array>;
  13153. /**
  13154. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13155. */
  13156. readonly orientation: Nullable<Float32Array>;
  13157. /**
  13158. * The angularVelocity of the device, values in array are [x,y,z].
  13159. */
  13160. readonly angularVelocity: Nullable<Float32Array>;
  13161. /**
  13162. * The angularAcceleration of the device, values in array are [x,y,z].
  13163. */
  13164. readonly angularAcceleration: Nullable<Float32Array>;
  13165. }
  13166. /**
  13167. * Interface representing a pose controlled object in Babylon.
  13168. * A pose controlled object has both regular pose values as well as pose values
  13169. * from an external device such as a VR head mounted display
  13170. */
  13171. export interface PoseControlled {
  13172. /**
  13173. * The position of the object in babylon space.
  13174. */
  13175. position: Vector3;
  13176. /**
  13177. * The rotation quaternion of the object in babylon space.
  13178. */
  13179. rotationQuaternion: Quaternion;
  13180. /**
  13181. * The position of the device in babylon space.
  13182. */
  13183. devicePosition?: Vector3;
  13184. /**
  13185. * The rotation quaternion of the device in babylon space.
  13186. */
  13187. deviceRotationQuaternion: Quaternion;
  13188. /**
  13189. * The raw pose coming from the device.
  13190. */
  13191. rawPose: Nullable<DevicePose>;
  13192. /**
  13193. * The scale of the device to be used when translating from device space to babylon space.
  13194. */
  13195. deviceScaleFactor: number;
  13196. /**
  13197. * Updates the poseControlled values based on the input device pose.
  13198. * @param poseData the pose data to update the object with
  13199. */
  13200. updateFromDevice(poseData: DevicePose): void;
  13201. }
  13202. /**
  13203. * Set of options to customize the webVRCamera
  13204. */
  13205. export interface WebVROptions {
  13206. /**
  13207. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13208. */
  13209. trackPosition?: boolean;
  13210. /**
  13211. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13212. */
  13213. positionScale?: number;
  13214. /**
  13215. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13216. */
  13217. displayName?: string;
  13218. /**
  13219. * Should the native controller meshes be initialized. (default: true)
  13220. */
  13221. controllerMeshes?: boolean;
  13222. /**
  13223. * Creating a default HemiLight only on controllers. (default: true)
  13224. */
  13225. defaultLightingOnControllers?: boolean;
  13226. /**
  13227. * If you don't want to use the default VR button of the helper. (default: false)
  13228. */
  13229. useCustomVRButton?: boolean;
  13230. /**
  13231. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13232. */
  13233. customVRButton?: HTMLButtonElement;
  13234. /**
  13235. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13236. */
  13237. rayLength?: number;
  13238. /**
  13239. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13240. */
  13241. defaultHeight?: number;
  13242. /**
  13243. * If multiview should be used if availible (default: false)
  13244. */
  13245. useMultiview?: boolean;
  13246. }
  13247. /**
  13248. * This represents a WebVR camera.
  13249. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13250. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13251. */
  13252. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13253. private webVROptions;
  13254. /**
  13255. * @hidden
  13256. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13257. */ private _vrDevice: any;
  13258. /**
  13259. * The rawPose of the vrDevice.
  13260. */
  13261. rawPose: Nullable<DevicePose>;
  13262. private _onVREnabled;
  13263. private _specsVersion;
  13264. private _attached;
  13265. private _frameData;
  13266. protected _descendants: Array<Node>;
  13267. private _deviceRoomPosition;
  13268. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  13269. private _standingMatrix;
  13270. /**
  13271. * Represents device position in babylon space.
  13272. */
  13273. devicePosition: Vector3;
  13274. /**
  13275. * Represents device rotation in babylon space.
  13276. */
  13277. deviceRotationQuaternion: Quaternion;
  13278. /**
  13279. * The scale of the device to be used when translating from device space to babylon space.
  13280. */
  13281. deviceScaleFactor: number;
  13282. private _deviceToWorld;
  13283. private _worldToDevice;
  13284. /**
  13285. * References to the webVR controllers for the vrDevice.
  13286. */
  13287. controllers: Array<WebVRController>;
  13288. /**
  13289. * Emits an event when a controller is attached.
  13290. */
  13291. onControllersAttachedObservable: Observable<WebVRController[]>;
  13292. /**
  13293. * Emits an event when a controller's mesh has been loaded;
  13294. */
  13295. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13296. /**
  13297. * Emits an event when the HMD's pose has been updated.
  13298. */
  13299. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13300. private _poseSet;
  13301. /**
  13302. * If the rig cameras be used as parent instead of this camera.
  13303. */
  13304. rigParenting: boolean;
  13305. private _lightOnControllers;
  13306. private _defaultHeight?;
  13307. /**
  13308. * Instantiates a WebVRFreeCamera.
  13309. * @param name The name of the WebVRFreeCamera
  13310. * @param position The starting anchor position for the camera
  13311. * @param scene The scene the camera belongs to
  13312. * @param webVROptions a set of customizable options for the webVRCamera
  13313. */
  13314. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13315. /**
  13316. * Gets the device distance from the ground in meters.
  13317. * @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.
  13318. */
  13319. deviceDistanceToRoomGround(): number;
  13320. /**
  13321. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13322. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13323. */
  13324. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13325. /**
  13326. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13327. * @returns A promise with a boolean set to if the standing matrix is supported.
  13328. */
  13329. useStandingMatrixAsync(): Promise<boolean>;
  13330. /**
  13331. * Disposes the camera
  13332. */
  13333. dispose(): void;
  13334. /**
  13335. * Gets a vrController by name.
  13336. * @param name The name of the controller to retreive
  13337. * @returns the controller matching the name specified or null if not found
  13338. */
  13339. getControllerByName(name: string): Nullable<WebVRController>;
  13340. private _leftController;
  13341. /**
  13342. * The controller corrisponding to the users left hand.
  13343. */
  13344. readonly leftController: Nullable<WebVRController>;
  13345. private _rightController;
  13346. /**
  13347. * The controller corrisponding to the users right hand.
  13348. */
  13349. readonly rightController: Nullable<WebVRController>;
  13350. /**
  13351. * Casts a ray forward from the vrCamera's gaze.
  13352. * @param length Length of the ray (default: 100)
  13353. * @returns the ray corrisponding to the gaze
  13354. */
  13355. getForwardRay(length?: number): Ray;
  13356. /**
  13357. * @hidden
  13358. * Updates the camera based on device's frame data
  13359. */ private _checkInputs(): void;
  13360. /**
  13361. * Updates the poseControlled values based on the input device pose.
  13362. * @param poseData Pose coming from the device
  13363. */
  13364. updateFromDevice(poseData: DevicePose): void;
  13365. private _htmlElementAttached;
  13366. private _detachIfAttached;
  13367. /**
  13368. * WebVR's attach control will start broadcasting frames to the device.
  13369. * Note that in certain browsers (chrome for example) this function must be called
  13370. * within a user-interaction callback. Example:
  13371. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13372. *
  13373. * @param element html element to attach the vrDevice to
  13374. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13375. */
  13376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13377. /**
  13378. * Detaches the camera from the html element and disables VR
  13379. *
  13380. * @param element html element to detach from
  13381. */
  13382. detachControl(element: HTMLElement): void;
  13383. /**
  13384. * @returns the name of this class
  13385. */
  13386. getClassName(): string;
  13387. /**
  13388. * Calls resetPose on the vrDisplay
  13389. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13390. */
  13391. resetToCurrentRotation(): void;
  13392. /**
  13393. * @hidden
  13394. * Updates the rig cameras (left and right eye)
  13395. */ private _updateRigCameras(): void;
  13396. private _workingVector;
  13397. private _oneVector;
  13398. private _workingMatrix;
  13399. private updateCacheCalled;
  13400. private _correctPositionIfNotTrackPosition;
  13401. /**
  13402. * @hidden
  13403. * Updates the cached values of the camera
  13404. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13405. */ private _updateCache(ignoreParentClass?: boolean): void;
  13406. /**
  13407. * @hidden
  13408. * Get current device position in babylon world
  13409. */ private _computeDevicePosition(): void;
  13410. /**
  13411. * Updates the current device position and rotation in the babylon world
  13412. */
  13413. update(): void;
  13414. /**
  13415. * @hidden
  13416. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13417. * @returns an identity matrix
  13418. */ private _getViewMatrix(): Matrix;
  13419. private _tmpMatrix;
  13420. /**
  13421. * This function is called by the two RIG cameras.
  13422. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13423. * @hidden
  13424. */ private _getWebVRViewMatrix(): Matrix;
  13425. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  13426. private _onGamepadConnectedObserver;
  13427. private _onGamepadDisconnectedObserver;
  13428. private _updateCacheWhenTrackingDisabledObserver;
  13429. /**
  13430. * Initializes the controllers and their meshes
  13431. */
  13432. initControllers(): void;
  13433. }
  13434. }
  13435. declare module BABYLON {
  13436. /**
  13437. * Size options for a post process
  13438. */
  13439. export type PostProcessOptions = {
  13440. width: number;
  13441. height: number;
  13442. };
  13443. /**
  13444. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13445. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13446. */
  13447. export class PostProcess {
  13448. /** Name of the PostProcess. */
  13449. name: string;
  13450. /**
  13451. * Gets or sets the unique id of the post process
  13452. */
  13453. uniqueId: number;
  13454. /**
  13455. * Width of the texture to apply the post process on
  13456. */
  13457. width: number;
  13458. /**
  13459. * Height of the texture to apply the post process on
  13460. */
  13461. height: number;
  13462. /**
  13463. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13464. * @hidden
  13465. */ private _outputTexture: Nullable<InternalTexture>;
  13466. /**
  13467. * Sampling mode used by the shader
  13468. * See https://doc.babylonjs.com/classes/3.1/texture
  13469. */
  13470. renderTargetSamplingMode: number;
  13471. /**
  13472. * Clear color to use when screen clearing
  13473. */
  13474. clearColor: Color4;
  13475. /**
  13476. * If the buffer needs to be cleared before applying the post process. (default: true)
  13477. * Should be set to false if shader will overwrite all previous pixels.
  13478. */
  13479. autoClear: boolean;
  13480. /**
  13481. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13482. */
  13483. alphaMode: number;
  13484. /**
  13485. * Sets the setAlphaBlendConstants of the babylon engine
  13486. */
  13487. alphaConstants: Color4;
  13488. /**
  13489. * Animations to be used for the post processing
  13490. */
  13491. animations: Animation[];
  13492. /**
  13493. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13494. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13495. */
  13496. enablePixelPerfectMode: boolean;
  13497. /**
  13498. * Force the postprocess to be applied without taking in account viewport
  13499. */
  13500. forceFullscreenViewport: boolean;
  13501. /**
  13502. * List of inspectable custom properties (used by the Inspector)
  13503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13504. */
  13505. inspectableCustomProperties: IInspectable[];
  13506. /**
  13507. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13508. *
  13509. * | Value | Type | Description |
  13510. * | ----- | ----------------------------------- | ----------- |
  13511. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13512. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13513. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13514. *
  13515. */
  13516. scaleMode: number;
  13517. /**
  13518. * Force textures to be a power of two (default: false)
  13519. */
  13520. alwaysForcePOT: boolean;
  13521. private _samples;
  13522. /**
  13523. * Number of sample textures (default: 1)
  13524. */
  13525. samples: number;
  13526. /**
  13527. * Modify the scale of the post process to be the same as the viewport (default: false)
  13528. */
  13529. adaptScaleToCurrentViewport: boolean;
  13530. private _camera;
  13531. private _scene;
  13532. private _engine;
  13533. private _options;
  13534. private _reusable;
  13535. private _textureType;
  13536. /**
  13537. * Smart array of input and output textures for the post process.
  13538. * @hidden
  13539. */ private _textures: SmartArray<InternalTexture>;
  13540. /**
  13541. * The index in _textures that corresponds to the output texture.
  13542. * @hidden
  13543. */ private _currentRenderTextureInd: number;
  13544. private _effect;
  13545. private _samplers;
  13546. private _fragmentUrl;
  13547. private _vertexUrl;
  13548. private _parameters;
  13549. private _scaleRatio;
  13550. protected _indexParameters: any;
  13551. private _shareOutputWithPostProcess;
  13552. private _texelSize;
  13553. private _forcedOutputTexture;
  13554. /**
  13555. * Returns the fragment url or shader name used in the post process.
  13556. * @returns the fragment url or name in the shader store.
  13557. */
  13558. getEffectName(): string;
  13559. /**
  13560. * An event triggered when the postprocess is activated.
  13561. */
  13562. onActivateObservable: Observable<Camera>;
  13563. private _onActivateObserver;
  13564. /**
  13565. * A function that is added to the onActivateObservable
  13566. */
  13567. onActivate: Nullable<(camera: Camera) => void>;
  13568. /**
  13569. * An event triggered when the postprocess changes its size.
  13570. */
  13571. onSizeChangedObservable: Observable<PostProcess>;
  13572. private _onSizeChangedObserver;
  13573. /**
  13574. * A function that is added to the onSizeChangedObservable
  13575. */
  13576. onSizeChanged: (postProcess: PostProcess) => void;
  13577. /**
  13578. * An event triggered when the postprocess applies its effect.
  13579. */
  13580. onApplyObservable: Observable<Effect>;
  13581. private _onApplyObserver;
  13582. /**
  13583. * A function that is added to the onApplyObservable
  13584. */
  13585. onApply: (effect: Effect) => void;
  13586. /**
  13587. * An event triggered before rendering the postprocess
  13588. */
  13589. onBeforeRenderObservable: Observable<Effect>;
  13590. private _onBeforeRenderObserver;
  13591. /**
  13592. * A function that is added to the onBeforeRenderObservable
  13593. */
  13594. onBeforeRender: (effect: Effect) => void;
  13595. /**
  13596. * An event triggered after rendering the postprocess
  13597. */
  13598. onAfterRenderObservable: Observable<Effect>;
  13599. private _onAfterRenderObserver;
  13600. /**
  13601. * A function that is added to the onAfterRenderObservable
  13602. */
  13603. onAfterRender: (efect: Effect) => void;
  13604. /**
  13605. * 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
  13606. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13607. */
  13608. inputTexture: InternalTexture;
  13609. /**
  13610. * Gets the camera which post process is applied to.
  13611. * @returns The camera the post process is applied to.
  13612. */
  13613. getCamera(): Camera;
  13614. /**
  13615. * Gets the texel size of the postprocess.
  13616. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13617. */
  13618. readonly texelSize: Vector2;
  13619. /**
  13620. * Creates a new instance PostProcess
  13621. * @param name The name of the PostProcess.
  13622. * @param fragmentUrl The url of the fragment shader to be used.
  13623. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13624. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13625. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13626. * @param camera The camera to apply the render pass to.
  13627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13628. * @param engine The engine which the post process will be applied. (default: current engine)
  13629. * @param reusable If the post process can be reused on the same frame. (default: false)
  13630. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13631. * @param textureType Type of textures used when performing the post process. (default: 0)
  13632. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13633. * @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
  13634. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13635. */
  13636. constructor(
  13637. /** Name of the PostProcess. */
  13638. 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);
  13639. /**
  13640. * Gets a string idenfifying the name of the class
  13641. * @returns "PostProcess" string
  13642. */
  13643. getClassName(): string;
  13644. /**
  13645. * Gets the engine which this post process belongs to.
  13646. * @returns The engine the post process was enabled with.
  13647. */
  13648. getEngine(): Engine;
  13649. /**
  13650. * The effect that is created when initializing the post process.
  13651. * @returns The created effect corrisponding the the postprocess.
  13652. */
  13653. getEffect(): Effect;
  13654. /**
  13655. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13656. * @param postProcess The post process to share the output with.
  13657. * @returns This post process.
  13658. */
  13659. shareOutputWith(postProcess: PostProcess): PostProcess;
  13660. /**
  13661. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13662. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13663. */
  13664. useOwnOutput(): void;
  13665. /**
  13666. * Updates the effect with the current post process compile time values and recompiles the shader.
  13667. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13668. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13669. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13670. * @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
  13671. * @param onCompiled Called when the shader has been compiled.
  13672. * @param onError Called if there is an error when compiling a shader.
  13673. */
  13674. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13675. /**
  13676. * The post process is reusable if it can be used multiple times within one frame.
  13677. * @returns If the post process is reusable
  13678. */
  13679. isReusable(): boolean;
  13680. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13681. markTextureDirty(): void;
  13682. /**
  13683. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13684. * 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.
  13685. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13686. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13687. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13688. * @returns The target texture that was bound to be written to.
  13689. */
  13690. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13691. /**
  13692. * If the post process is supported.
  13693. */
  13694. readonly isSupported: boolean;
  13695. /**
  13696. * The aspect ratio of the output texture.
  13697. */
  13698. readonly aspectRatio: number;
  13699. /**
  13700. * Get a value indicating if the post-process is ready to be used
  13701. * @returns true if the post-process is ready (shader is compiled)
  13702. */
  13703. isReady(): boolean;
  13704. /**
  13705. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13706. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13707. */
  13708. apply(): Nullable<Effect>;
  13709. private _disposeTextures;
  13710. /**
  13711. * Disposes the post process.
  13712. * @param camera The camera to dispose the post process on.
  13713. */
  13714. dispose(camera?: Camera): void;
  13715. }
  13716. }
  13717. declare module BABYLON {
  13718. /**
  13719. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13720. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13721. */
  13722. export class PostProcessManager {
  13723. private _scene;
  13724. private _indexBuffer;
  13725. private _vertexBuffers;
  13726. /**
  13727. * Creates a new instance PostProcess
  13728. * @param scene The scene that the post process is associated with.
  13729. */
  13730. constructor(scene: Scene);
  13731. private _prepareBuffers;
  13732. private _buildIndexBuffer;
  13733. /**
  13734. * Rebuilds the vertex buffers of the manager.
  13735. * @hidden
  13736. */ private _rebuild(): void;
  13737. /**
  13738. * Prepares a frame to be run through a post process.
  13739. * @param sourceTexture The input texture to the post procesess. (default: null)
  13740. * @param postProcesses An array of post processes to be run. (default: null)
  13741. * @returns True if the post processes were able to be run.
  13742. * @hidden
  13743. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13744. /**
  13745. * Manually render a set of post processes to a texture.
  13746. * @param postProcesses An array of post processes to be run.
  13747. * @param targetTexture The target texture to render to.
  13748. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13749. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13750. * @param lodLevel defines which lod of the texture to render to
  13751. */
  13752. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13753. /**
  13754. * Finalize the result of the output of the postprocesses.
  13755. * @param doNotPresent If true the result will not be displayed to the screen.
  13756. * @param targetTexture The target texture to render to.
  13757. * @param faceIndex The index of the face to bind the target texture to.
  13758. * @param postProcesses The array of post processes to render.
  13759. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13760. * @hidden
  13761. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13762. /**
  13763. * Disposes of the post process manager.
  13764. */
  13765. dispose(): void;
  13766. }
  13767. }
  13768. declare module BABYLON {
  13769. interface AbstractScene {
  13770. /**
  13771. * The list of procedural textures added to the scene
  13772. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13773. */
  13774. proceduralTextures: Array<ProceduralTexture>;
  13775. }
  13776. /**
  13777. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  13778. * in a given scene.
  13779. */
  13780. export class ProceduralTextureSceneComponent implements ISceneComponent {
  13781. /**
  13782. * The component name helpfull to identify the component in the list of scene components.
  13783. */
  13784. readonly name: string;
  13785. /**
  13786. * The scene the component belongs to.
  13787. */
  13788. scene: Scene;
  13789. /**
  13790. * Creates a new instance of the component for the given scene
  13791. * @param scene Defines the scene to register the component in
  13792. */
  13793. constructor(scene: Scene);
  13794. /**
  13795. * Registers the component in a given scene
  13796. */
  13797. register(): void;
  13798. /**
  13799. * Rebuilds the elements related to this component in case of
  13800. * context lost for instance.
  13801. */
  13802. rebuild(): void;
  13803. /**
  13804. * Disposes the component and the associated ressources.
  13805. */
  13806. dispose(): void;
  13807. private _beforeClear;
  13808. }
  13809. }
  13810. declare module BABYLON {
  13811. interface Engine {
  13812. /**
  13813. * Creates a new render target cube texture
  13814. * @param size defines the size of the texture
  13815. * @param options defines the options used to create the texture
  13816. * @returns a new render target cube texture stored in an InternalTexture
  13817. */
  13818. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  13819. }
  13820. }
  13821. declare module BABYLON {
  13822. /** @hidden */
  13823. export var proceduralVertexShader: {
  13824. name: string;
  13825. shader: string;
  13826. };
  13827. }
  13828. declare module BABYLON {
  13829. /**
  13830. * 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.
  13831. * This is the base class of any Procedural texture and contains most of the shareable code.
  13832. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13833. */
  13834. export class ProceduralTexture extends Texture {
  13835. isCube: boolean;
  13836. /**
  13837. * Define if the texture is enabled or not (disabled texture will not render)
  13838. */
  13839. isEnabled: boolean;
  13840. /**
  13841. * Define if the texture must be cleared before rendering (default is true)
  13842. */
  13843. autoClear: boolean;
  13844. /**
  13845. * Callback called when the texture is generated
  13846. */
  13847. onGenerated: () => void;
  13848. /**
  13849. * Event raised when the texture is generated
  13850. */
  13851. onGeneratedObservable: Observable<ProceduralTexture>;
  13852. /** @hidden */ private _generateMipMaps: boolean;
  13853. /** @hidden **/ private _effect: Effect;
  13854. /** @hidden */ private _textures: {
  13855. [key: string]: Texture;
  13856. };
  13857. private _size;
  13858. private _currentRefreshId;
  13859. private _refreshRate;
  13860. private _vertexBuffers;
  13861. private _indexBuffer;
  13862. private _uniforms;
  13863. private _samplers;
  13864. private _fragment;
  13865. private _floats;
  13866. private _ints;
  13867. private _floatsArrays;
  13868. private _colors3;
  13869. private _colors4;
  13870. private _vectors2;
  13871. private _vectors3;
  13872. private _matrices;
  13873. private _fallbackTexture;
  13874. private _fallbackTextureUsed;
  13875. private _engine;
  13876. private _cachedDefines;
  13877. private _contentUpdateId;
  13878. private _contentData;
  13879. /**
  13880. * Instantiates a new procedural texture.
  13881. * 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.
  13882. * This is the base class of any Procedural texture and contains most of the shareable code.
  13883. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  13884. * @param name Define the name of the texture
  13885. * @param size Define the size of the texture to create
  13886. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  13887. * @param scene Define the scene the texture belongs to
  13888. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  13889. * @param generateMipMaps Define if the texture should creates mip maps or not
  13890. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  13891. */
  13892. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  13893. /**
  13894. * The effect that is created when initializing the post process.
  13895. * @returns The created effect corrisponding the the postprocess.
  13896. */
  13897. getEffect(): Effect;
  13898. /**
  13899. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  13900. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  13901. */
  13902. getContent(): Nullable<ArrayBufferView>;
  13903. private _createIndexBuffer;
  13904. /** @hidden */ private _rebuild(): void;
  13905. /**
  13906. * Resets the texture in order to recreate its associated resources.
  13907. * This can be called in case of context loss
  13908. */
  13909. reset(): void;
  13910. protected _getDefines(): string;
  13911. /**
  13912. * Is the texture ready to be used ? (rendered at least once)
  13913. * @returns true if ready, otherwise, false.
  13914. */
  13915. isReady(): boolean;
  13916. /**
  13917. * Resets the refresh counter of the texture and start bak from scratch.
  13918. * Could be useful to regenerate the texture if it is setup to render only once.
  13919. */
  13920. resetRefreshCounter(): void;
  13921. /**
  13922. * Set the fragment shader to use in order to render the texture.
  13923. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  13924. */
  13925. setFragment(fragment: any): void;
  13926. /**
  13927. * Define the refresh rate of the texture or the rendering frequency.
  13928. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  13929. */
  13930. refreshRate: number;
  13931. /** @hidden */ private _shouldRender(): boolean;
  13932. /**
  13933. * Get the size the texture is rendering at.
  13934. * @returns the size (texture is always squared)
  13935. */
  13936. getRenderSize(): number;
  13937. /**
  13938. * Resize the texture to new value.
  13939. * @param size Define the new size the texture should have
  13940. * @param generateMipMaps Define whether the new texture should create mip maps
  13941. */
  13942. resize(size: number, generateMipMaps: boolean): void;
  13943. private _checkUniform;
  13944. /**
  13945. * Set a texture in the shader program used to render.
  13946. * @param name Define the name of the uniform samplers as defined in the shader
  13947. * @param texture Define the texture to bind to this sampler
  13948. * @return the texture itself allowing "fluent" like uniform updates
  13949. */
  13950. setTexture(name: string, texture: Texture): ProceduralTexture;
  13951. /**
  13952. * Set a float in the shader.
  13953. * @param name Define the name of the uniform as defined in the shader
  13954. * @param value Define the value to give to the uniform
  13955. * @return the texture itself allowing "fluent" like uniform updates
  13956. */
  13957. setFloat(name: string, value: number): ProceduralTexture;
  13958. /**
  13959. * Set a int in the shader.
  13960. * @param name Define the name of the uniform as defined in the shader
  13961. * @param value Define the value to give to the uniform
  13962. * @return the texture itself allowing "fluent" like uniform updates
  13963. */
  13964. setInt(name: string, value: number): ProceduralTexture;
  13965. /**
  13966. * Set an array of floats in the shader.
  13967. * @param name Define the name of the uniform as defined in the shader
  13968. * @param value Define the value to give to the uniform
  13969. * @return the texture itself allowing "fluent" like uniform updates
  13970. */
  13971. setFloats(name: string, value: number[]): ProceduralTexture;
  13972. /**
  13973. * Set a vec3 in the shader from a Color3.
  13974. * @param name Define the name of the uniform as defined in the shader
  13975. * @param value Define the value to give to the uniform
  13976. * @return the texture itself allowing "fluent" like uniform updates
  13977. */
  13978. setColor3(name: string, value: Color3): ProceduralTexture;
  13979. /**
  13980. * Set a vec4 in the shader from a Color4.
  13981. * @param name Define the name of the uniform as defined in the shader
  13982. * @param value Define the value to give to the uniform
  13983. * @return the texture itself allowing "fluent" like uniform updates
  13984. */
  13985. setColor4(name: string, value: Color4): ProceduralTexture;
  13986. /**
  13987. * Set a vec2 in the shader from a Vector2.
  13988. * @param name Define the name of the uniform as defined in the shader
  13989. * @param value Define the value to give to the uniform
  13990. * @return the texture itself allowing "fluent" like uniform updates
  13991. */
  13992. setVector2(name: string, value: Vector2): ProceduralTexture;
  13993. /**
  13994. * Set a vec3 in the shader from a Vector3.
  13995. * @param name Define the name of the uniform as defined in the shader
  13996. * @param value Define the value to give to the uniform
  13997. * @return the texture itself allowing "fluent" like uniform updates
  13998. */
  13999. setVector3(name: string, value: Vector3): ProceduralTexture;
  14000. /**
  14001. * Set a mat4 in the shader from a MAtrix.
  14002. * @param name Define the name of the uniform as defined in the shader
  14003. * @param value Define the value to give to the uniform
  14004. * @return the texture itself allowing "fluent" like uniform updates
  14005. */
  14006. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14007. /**
  14008. * Render the texture to its associated render target.
  14009. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14010. */
  14011. render(useCameraPostProcess?: boolean): void;
  14012. /**
  14013. * Clone the texture.
  14014. * @returns the cloned texture
  14015. */
  14016. clone(): ProceduralTexture;
  14017. /**
  14018. * Dispose the texture and release its asoociated resources.
  14019. */
  14020. dispose(): void;
  14021. }
  14022. }
  14023. declare module BABYLON {
  14024. /**
  14025. * This represents the base class for particle system in Babylon.
  14026. * 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.
  14027. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14028. * @example https://doc.babylonjs.com/babylon101/particles
  14029. */
  14030. export class BaseParticleSystem {
  14031. /**
  14032. * Source color is added to the destination color without alpha affecting the result
  14033. */
  14034. static BLENDMODE_ONEONE: number;
  14035. /**
  14036. * Blend current color and particle color using particle’s alpha
  14037. */
  14038. static BLENDMODE_STANDARD: number;
  14039. /**
  14040. * Add current color and particle color multiplied by particle’s alpha
  14041. */
  14042. static BLENDMODE_ADD: number;
  14043. /**
  14044. * Multiply current color with particle color
  14045. */
  14046. static BLENDMODE_MULTIPLY: number;
  14047. /**
  14048. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14049. */
  14050. static BLENDMODE_MULTIPLYADD: number;
  14051. /**
  14052. * List of animations used by the particle system.
  14053. */
  14054. animations: Animation[];
  14055. /**
  14056. * The id of the Particle system.
  14057. */
  14058. id: string;
  14059. /**
  14060. * The friendly name of the Particle system.
  14061. */
  14062. name: string;
  14063. /**
  14064. * The rendering group used by the Particle system to chose when to render.
  14065. */
  14066. renderingGroupId: number;
  14067. /**
  14068. * The emitter represents the Mesh or position we are attaching the particle system to.
  14069. */
  14070. emitter: Nullable<AbstractMesh | Vector3>;
  14071. /**
  14072. * The maximum number of particles to emit per frame
  14073. */
  14074. emitRate: number;
  14075. /**
  14076. * If you want to launch only a few particles at once, that can be done, as well.
  14077. */
  14078. manualEmitCount: number;
  14079. /**
  14080. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14081. */
  14082. updateSpeed: number;
  14083. /**
  14084. * The amount of time the particle system is running (depends of the overall update speed).
  14085. */
  14086. targetStopDuration: number;
  14087. /**
  14088. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14089. */
  14090. disposeOnStop: boolean;
  14091. /**
  14092. * Minimum power of emitting particles.
  14093. */
  14094. minEmitPower: number;
  14095. /**
  14096. * Maximum power of emitting particles.
  14097. */
  14098. maxEmitPower: number;
  14099. /**
  14100. * Minimum life time of emitting particles.
  14101. */
  14102. minLifeTime: number;
  14103. /**
  14104. * Maximum life time of emitting particles.
  14105. */
  14106. maxLifeTime: number;
  14107. /**
  14108. * Minimum Size of emitting particles.
  14109. */
  14110. minSize: number;
  14111. /**
  14112. * Maximum Size of emitting particles.
  14113. */
  14114. maxSize: number;
  14115. /**
  14116. * Minimum scale of emitting particles on X axis.
  14117. */
  14118. minScaleX: number;
  14119. /**
  14120. * Maximum scale of emitting particles on X axis.
  14121. */
  14122. maxScaleX: number;
  14123. /**
  14124. * Minimum scale of emitting particles on Y axis.
  14125. */
  14126. minScaleY: number;
  14127. /**
  14128. * Maximum scale of emitting particles on Y axis.
  14129. */
  14130. maxScaleY: number;
  14131. /**
  14132. * Gets or sets the minimal initial rotation in radians.
  14133. */
  14134. minInitialRotation: number;
  14135. /**
  14136. * Gets or sets the maximal initial rotation in radians.
  14137. */
  14138. maxInitialRotation: number;
  14139. /**
  14140. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14141. */
  14142. minAngularSpeed: number;
  14143. /**
  14144. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14145. */
  14146. maxAngularSpeed: number;
  14147. /**
  14148. * The texture used to render each particle. (this can be a spritesheet)
  14149. */
  14150. particleTexture: Nullable<Texture>;
  14151. /**
  14152. * The layer mask we are rendering the particles through.
  14153. */
  14154. layerMask: number;
  14155. /**
  14156. * This can help using your own shader to render the particle system.
  14157. * The according effect will be created
  14158. */
  14159. customShader: any;
  14160. /**
  14161. * By default particle system starts as soon as they are created. This prevents the
  14162. * automatic start to happen and let you decide when to start emitting particles.
  14163. */
  14164. preventAutoStart: boolean;
  14165. private _noiseTexture;
  14166. /**
  14167. * Gets or sets a texture used to add random noise to particle positions
  14168. */
  14169. noiseTexture: Nullable<ProceduralTexture>;
  14170. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14171. noiseStrength: Vector3;
  14172. /**
  14173. * Callback triggered when the particle animation is ending.
  14174. */
  14175. onAnimationEnd: Nullable<() => void>;
  14176. /**
  14177. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14178. */
  14179. blendMode: number;
  14180. /**
  14181. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14182. * to override the particles.
  14183. */
  14184. forceDepthWrite: boolean;
  14185. /** 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 */
  14186. preWarmCycles: number;
  14187. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14188. preWarmStepOffset: number;
  14189. /**
  14190. * 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)
  14191. */
  14192. spriteCellChangeSpeed: number;
  14193. /**
  14194. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14195. */
  14196. startSpriteCellID: number;
  14197. /**
  14198. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14199. */
  14200. endSpriteCellID: number;
  14201. /**
  14202. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14203. */
  14204. spriteCellWidth: number;
  14205. /**
  14206. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14207. */
  14208. spriteCellHeight: number;
  14209. /**
  14210. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14211. */
  14212. spriteRandomStartCell: boolean;
  14213. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14214. translationPivot: Vector2;
  14215. /** @hidden */
  14216. protected _isAnimationSheetEnabled: boolean;
  14217. /**
  14218. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14219. */
  14220. beginAnimationOnStart: boolean;
  14221. /**
  14222. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14223. */
  14224. beginAnimationFrom: number;
  14225. /**
  14226. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14227. */
  14228. beginAnimationTo: number;
  14229. /**
  14230. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14231. */
  14232. beginAnimationLoop: boolean;
  14233. /**
  14234. * Gets or sets a world offset applied to all particles
  14235. */
  14236. worldOffset: Vector3;
  14237. /**
  14238. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14239. */
  14240. isAnimationSheetEnabled: boolean;
  14241. /**
  14242. * Get hosting scene
  14243. * @returns the scene
  14244. */
  14245. getScene(): Scene;
  14246. /**
  14247. * You can use gravity if you want to give an orientation to your particles.
  14248. */
  14249. gravity: Vector3;
  14250. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14251. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14252. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14253. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14254. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14255. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14256. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14257. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14258. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14259. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14260. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14261. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14262. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14263. /**
  14264. * Defines the delay in milliseconds before starting the system (0 by default)
  14265. */
  14266. startDelay: number;
  14267. /**
  14268. * Gets the current list of drag gradients.
  14269. * You must use addDragGradient and removeDragGradient to udpate this list
  14270. * @returns the list of drag gradients
  14271. */
  14272. getDragGradients(): Nullable<Array<FactorGradient>>;
  14273. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14274. limitVelocityDamping: number;
  14275. /**
  14276. * Gets the current list of limit velocity gradients.
  14277. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14278. * @returns the list of limit velocity gradients
  14279. */
  14280. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14281. /**
  14282. * Gets the current list of color gradients.
  14283. * You must use addColorGradient and removeColorGradient to udpate this list
  14284. * @returns the list of color gradients
  14285. */
  14286. getColorGradients(): Nullable<Array<ColorGradient>>;
  14287. /**
  14288. * Gets the current list of size gradients.
  14289. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14290. * @returns the list of size gradients
  14291. */
  14292. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14293. /**
  14294. * Gets the current list of color remap gradients.
  14295. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14296. * @returns the list of color remap gradients
  14297. */
  14298. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14299. /**
  14300. * Gets the current list of alpha remap gradients.
  14301. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14302. * @returns the list of alpha remap gradients
  14303. */
  14304. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14305. /**
  14306. * Gets the current list of life time gradients.
  14307. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14308. * @returns the list of life time gradients
  14309. */
  14310. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14311. /**
  14312. * Gets the current list of angular speed gradients.
  14313. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14314. * @returns the list of angular speed gradients
  14315. */
  14316. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14317. /**
  14318. * Gets the current list of velocity gradients.
  14319. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14320. * @returns the list of velocity gradients
  14321. */
  14322. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14323. /**
  14324. * Gets the current list of start size gradients.
  14325. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14326. * @returns the list of start size gradients
  14327. */
  14328. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14329. /**
  14330. * Gets the current list of emit rate gradients.
  14331. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14332. * @returns the list of emit rate gradients
  14333. */
  14334. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14335. /**
  14336. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14337. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14338. */
  14339. direction1: Vector3;
  14340. /**
  14341. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14342. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14343. */
  14344. direction2: Vector3;
  14345. /**
  14346. * 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.
  14347. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14348. */
  14349. minEmitBox: Vector3;
  14350. /**
  14351. * 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.
  14352. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14353. */
  14354. maxEmitBox: Vector3;
  14355. /**
  14356. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14357. */
  14358. color1: Color4;
  14359. /**
  14360. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14361. */
  14362. color2: Color4;
  14363. /**
  14364. * Color the particle will have at the end of its lifetime
  14365. */
  14366. colorDead: Color4;
  14367. /**
  14368. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14369. */
  14370. textureMask: Color4;
  14371. /**
  14372. * The particle emitter type defines the emitter used by the particle system.
  14373. * It can be for example box, sphere, or cone...
  14374. */
  14375. particleEmitterType: IParticleEmitterType;
  14376. /** @hidden */ private _isSubEmitter: boolean;
  14377. /**
  14378. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14379. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14380. */
  14381. billboardMode: number;
  14382. protected _isBillboardBased: boolean;
  14383. /**
  14384. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14385. */
  14386. isBillboardBased: boolean;
  14387. /**
  14388. * The scene the particle system belongs to.
  14389. */
  14390. protected _scene: Scene;
  14391. /**
  14392. * Local cache of defines for image processing.
  14393. */
  14394. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14395. /**
  14396. * Default configuration related to image processing available in the standard Material.
  14397. */
  14398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14399. /**
  14400. * Gets the image processing configuration used either in this material.
  14401. */
  14402. /**
  14403. * Sets the Default image processing configuration used either in the this material.
  14404. *
  14405. * If sets to null, the scene one is in use.
  14406. */
  14407. imageProcessingConfiguration: ImageProcessingConfiguration;
  14408. /**
  14409. * Attaches a new image processing configuration to the Standard Material.
  14410. * @param configuration
  14411. */
  14412. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14413. /** @hidden */
  14414. protected _reset(): void;
  14415. /** @hidden */
  14416. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14417. /**
  14418. * Instantiates a particle system.
  14419. * 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.
  14420. * @param name The name of the particle system
  14421. */
  14422. constructor(name: string);
  14423. /**
  14424. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14425. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14426. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14427. * @returns the emitter
  14428. */
  14429. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14430. /**
  14431. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14432. * @param radius The radius of the hemisphere to emit from
  14433. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14434. * @returns the emitter
  14435. */
  14436. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14437. /**
  14438. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14439. * @param radius The radius of the sphere to emit from
  14440. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14441. * @returns the emitter
  14442. */
  14443. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14444. /**
  14445. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14446. * @param radius The radius of the sphere to emit from
  14447. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14448. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14449. * @returns the emitter
  14450. */
  14451. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14452. /**
  14453. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14454. * @param radius The radius of the emission cylinder
  14455. * @param height The height of the emission cylinder
  14456. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14457. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14458. * @returns the emitter
  14459. */
  14460. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14461. /**
  14462. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14463. * @param radius The radius of the cylinder to emit from
  14464. * @param height The height of the emission cylinder
  14465. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14466. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14467. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14468. * @returns the emitter
  14469. */
  14470. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14471. /**
  14472. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14473. * @param radius The radius of the cone to emit from
  14474. * @param angle The base angle of the cone
  14475. * @returns the emitter
  14476. */
  14477. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14478. /**
  14479. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14480. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14481. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14482. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14483. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14484. * @returns the emitter
  14485. */
  14486. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14487. }
  14488. }
  14489. declare module BABYLON {
  14490. /**
  14491. * Type of sub emitter
  14492. */
  14493. export enum SubEmitterType {
  14494. /**
  14495. * Attached to the particle over it's lifetime
  14496. */
  14497. ATTACHED = 0,
  14498. /**
  14499. * Created when the particle dies
  14500. */
  14501. END = 1
  14502. }
  14503. /**
  14504. * Sub emitter class used to emit particles from an existing particle
  14505. */
  14506. export class SubEmitter {
  14507. /**
  14508. * the particle system to be used by the sub emitter
  14509. */
  14510. particleSystem: ParticleSystem;
  14511. /**
  14512. * Type of the submitter (Default: END)
  14513. */
  14514. type: SubEmitterType;
  14515. /**
  14516. * 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)
  14517. * Note: This only is supported when using an emitter of type Mesh
  14518. */
  14519. inheritDirection: boolean;
  14520. /**
  14521. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14522. */
  14523. inheritedVelocityAmount: number;
  14524. /**
  14525. * Creates a sub emitter
  14526. * @param particleSystem the particle system to be used by the sub emitter
  14527. */
  14528. constructor(
  14529. /**
  14530. * the particle system to be used by the sub emitter
  14531. */
  14532. particleSystem: ParticleSystem);
  14533. /**
  14534. * Clones the sub emitter
  14535. * @returns the cloned sub emitter
  14536. */
  14537. clone(): SubEmitter;
  14538. /**
  14539. * Serialize current object to a JSON object
  14540. * @returns the serialized object
  14541. */
  14542. serialize(): any;
  14543. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14544. /**
  14545. * Creates a new SubEmitter from a serialized JSON version
  14546. * @param serializationObject defines the JSON object to read from
  14547. * @param scene defines the hosting scene
  14548. * @param rootUrl defines the rootUrl for data loading
  14549. * @returns a new SubEmitter
  14550. */
  14551. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14552. /** Release associated resources */
  14553. dispose(): void;
  14554. }
  14555. }
  14556. declare module BABYLON {
  14557. /** @hidden */
  14558. export var clipPlaneFragmentDeclaration: {
  14559. name: string;
  14560. shader: string;
  14561. };
  14562. }
  14563. declare module BABYLON {
  14564. /** @hidden */
  14565. export var imageProcessingDeclaration: {
  14566. name: string;
  14567. shader: string;
  14568. };
  14569. }
  14570. declare module BABYLON {
  14571. /** @hidden */
  14572. export var imageProcessingFunctions: {
  14573. name: string;
  14574. shader: string;
  14575. };
  14576. }
  14577. declare module BABYLON {
  14578. /** @hidden */
  14579. export var clipPlaneFragment: {
  14580. name: string;
  14581. shader: string;
  14582. };
  14583. }
  14584. declare module BABYLON {
  14585. /** @hidden */
  14586. export var particlesPixelShader: {
  14587. name: string;
  14588. shader: string;
  14589. };
  14590. }
  14591. declare module BABYLON {
  14592. /** @hidden */
  14593. export var clipPlaneVertexDeclaration: {
  14594. name: string;
  14595. shader: string;
  14596. };
  14597. }
  14598. declare module BABYLON {
  14599. /** @hidden */
  14600. export var clipPlaneVertex: {
  14601. name: string;
  14602. shader: string;
  14603. };
  14604. }
  14605. declare module BABYLON {
  14606. /** @hidden */
  14607. export var particlesVertexShader: {
  14608. name: string;
  14609. shader: string;
  14610. };
  14611. }
  14612. declare module BABYLON {
  14613. /**
  14614. * This represents a particle system in Babylon.
  14615. * 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.
  14616. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14617. * @example https://doc.babylonjs.com/babylon101/particles
  14618. */
  14619. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14620. /**
  14621. * Billboard mode will only apply to Y axis
  14622. */
  14623. static readonly BILLBOARDMODE_Y: number;
  14624. /**
  14625. * Billboard mode will apply to all axes
  14626. */
  14627. static readonly BILLBOARDMODE_ALL: number;
  14628. /**
  14629. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  14630. */
  14631. static readonly BILLBOARDMODE_STRETCHED: number;
  14632. /**
  14633. * This function can be defined to provide custom update for active particles.
  14634. * This function will be called instead of regular update (age, position, color, etc.).
  14635. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14636. */
  14637. updateFunction: (particles: Particle[]) => void;
  14638. private _emitterWorldMatrix;
  14639. /**
  14640. * This function can be defined to specify initial direction for every new particle.
  14641. * It by default use the emitterType defined function
  14642. */
  14643. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14644. /**
  14645. * This function can be defined to specify initial position for every new particle.
  14646. * It by default use the emitterType defined function
  14647. */
  14648. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14649. /**
  14650. * @hidden
  14651. */ private _inheritedVelocityOffset: Vector3;
  14652. /**
  14653. * An event triggered when the system is disposed
  14654. */
  14655. onDisposeObservable: Observable<ParticleSystem>;
  14656. private _onDisposeObserver;
  14657. /**
  14658. * Sets a callback that will be triggered when the system is disposed
  14659. */
  14660. onDispose: () => void;
  14661. private _particles;
  14662. private _epsilon;
  14663. private _capacity;
  14664. private _stockParticles;
  14665. private _newPartsExcess;
  14666. private _vertexData;
  14667. private _vertexBuffer;
  14668. private _vertexBuffers;
  14669. private _spriteBuffer;
  14670. private _indexBuffer;
  14671. private _effect;
  14672. private _customEffect;
  14673. private _cachedDefines;
  14674. private _scaledColorStep;
  14675. private _colorDiff;
  14676. private _scaledDirection;
  14677. private _scaledGravity;
  14678. private _currentRenderId;
  14679. private _alive;
  14680. private _useInstancing;
  14681. private _started;
  14682. private _stopped;
  14683. private _actualFrame;
  14684. private _scaledUpdateSpeed;
  14685. private _vertexBufferSize;
  14686. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  14687. /** @hidden */ private _currentEmitRate1: number;
  14688. /** @hidden */ private _currentEmitRate2: number;
  14689. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  14690. /** @hidden */ private _currentStartSize1: number;
  14691. /** @hidden */ private _currentStartSize2: number;
  14692. private readonly _rawTextureWidth;
  14693. private _rampGradientsTexture;
  14694. private _useRampGradients;
  14695. /** Gets or sets a boolean indicating that ramp gradients must be used
  14696. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14697. */
  14698. useRampGradients: boolean;
  14699. /**
  14700. * 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.
  14701. * 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: [])
  14702. */
  14703. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  14704. private _subEmitters;
  14705. /**
  14706. * @hidden
  14707. * If the particle systems emitter should be disposed when the particle system is disposed
  14708. */ private _disposeEmitterOnDispose: boolean;
  14709. /**
  14710. * The current active Sub-systems, this property is used by the root particle system only.
  14711. */
  14712. activeSubSystems: Array<ParticleSystem>;
  14713. private _rootParticleSystem;
  14714. /**
  14715. * Gets the current list of active particles
  14716. */
  14717. readonly particles: Particle[];
  14718. /**
  14719. * Returns the string "ParticleSystem"
  14720. * @returns a string containing the class name
  14721. */
  14722. getClassName(): string;
  14723. /**
  14724. * Instantiates a particle system.
  14725. * 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.
  14726. * @param name The name of the particle system
  14727. * @param capacity The max number of particles alive at the same time
  14728. * @param scene The scene the particle system belongs to
  14729. * @param customEffect a custom effect used to change the way particles are rendered by default
  14730. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14731. * @param epsilon Offset used to render the particles
  14732. */
  14733. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14734. private _addFactorGradient;
  14735. private _removeFactorGradient;
  14736. /**
  14737. * Adds a new life time gradient
  14738. * @param gradient defines the gradient to use (between 0 and 1)
  14739. * @param factor defines the life time factor to affect to the specified gradient
  14740. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14741. * @returns the current particle system
  14742. */
  14743. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14744. /**
  14745. * Remove a specific life time gradient
  14746. * @param gradient defines the gradient to remove
  14747. * @returns the current particle system
  14748. */
  14749. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14750. /**
  14751. * Adds a new size gradient
  14752. * @param gradient defines the gradient to use (between 0 and 1)
  14753. * @param factor defines the size factor to affect to the specified gradient
  14754. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14755. * @returns the current particle system
  14756. */
  14757. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14758. /**
  14759. * Remove a specific size gradient
  14760. * @param gradient defines the gradient to remove
  14761. * @returns the current particle system
  14762. */
  14763. removeSizeGradient(gradient: number): IParticleSystem;
  14764. /**
  14765. * Adds a new color remap gradient
  14766. * @param gradient defines the gradient to use (between 0 and 1)
  14767. * @param min defines the color remap minimal range
  14768. * @param max defines the color remap maximal range
  14769. * @returns the current particle system
  14770. */
  14771. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14772. /**
  14773. * Remove a specific color remap gradient
  14774. * @param gradient defines the gradient to remove
  14775. * @returns the current particle system
  14776. */
  14777. removeColorRemapGradient(gradient: number): IParticleSystem;
  14778. /**
  14779. * Adds a new alpha remap gradient
  14780. * @param gradient defines the gradient to use (between 0 and 1)
  14781. * @param min defines the alpha remap minimal range
  14782. * @param max defines the alpha remap maximal range
  14783. * @returns the current particle system
  14784. */
  14785. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14786. /**
  14787. * Remove a specific alpha remap gradient
  14788. * @param gradient defines the gradient to remove
  14789. * @returns the current particle system
  14790. */
  14791. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  14792. /**
  14793. * Adds a new angular speed gradient
  14794. * @param gradient defines the gradient to use (between 0 and 1)
  14795. * @param factor defines the angular speed to affect to the specified gradient
  14796. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14797. * @returns the current particle system
  14798. */
  14799. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14800. /**
  14801. * Remove a specific angular speed gradient
  14802. * @param gradient defines the gradient to remove
  14803. * @returns the current particle system
  14804. */
  14805. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14806. /**
  14807. * Adds a new velocity gradient
  14808. * @param gradient defines the gradient to use (between 0 and 1)
  14809. * @param factor defines the velocity to affect to the specified gradient
  14810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14811. * @returns the current particle system
  14812. */
  14813. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14814. /**
  14815. * Remove a specific velocity gradient
  14816. * @param gradient defines the gradient to remove
  14817. * @returns the current particle system
  14818. */
  14819. removeVelocityGradient(gradient: number): IParticleSystem;
  14820. /**
  14821. * Adds a new limit velocity gradient
  14822. * @param gradient defines the gradient to use (between 0 and 1)
  14823. * @param factor defines the limit velocity value to affect to the specified gradient
  14824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14825. * @returns the current particle system
  14826. */
  14827. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14828. /**
  14829. * Remove a specific limit velocity gradient
  14830. * @param gradient defines the gradient to remove
  14831. * @returns the current particle system
  14832. */
  14833. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14834. /**
  14835. * Adds a new drag gradient
  14836. * @param gradient defines the gradient to use (between 0 and 1)
  14837. * @param factor defines the drag value to affect to the specified gradient
  14838. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14839. * @returns the current particle system
  14840. */
  14841. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14842. /**
  14843. * Remove a specific drag gradient
  14844. * @param gradient defines the gradient to remove
  14845. * @returns the current particle system
  14846. */
  14847. removeDragGradient(gradient: number): IParticleSystem;
  14848. /**
  14849. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14850. * @param gradient defines the gradient to use (between 0 and 1)
  14851. * @param factor defines the emit rate value to affect to the specified gradient
  14852. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14853. * @returns the current particle system
  14854. */
  14855. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14856. /**
  14857. * Remove a specific emit rate gradient
  14858. * @param gradient defines the gradient to remove
  14859. * @returns the current particle system
  14860. */
  14861. removeEmitRateGradient(gradient: number): IParticleSystem;
  14862. /**
  14863. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14864. * @param gradient defines the gradient to use (between 0 and 1)
  14865. * @param factor defines the start size value to affect to the specified gradient
  14866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14867. * @returns the current particle system
  14868. */
  14869. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14870. /**
  14871. * Remove a specific start size gradient
  14872. * @param gradient defines the gradient to remove
  14873. * @returns the current particle system
  14874. */
  14875. removeStartSizeGradient(gradient: number): IParticleSystem;
  14876. private _createRampGradientTexture;
  14877. /**
  14878. * Gets the current list of ramp gradients.
  14879. * You must use addRampGradient and removeRampGradient to udpate this list
  14880. * @returns the list of ramp gradients
  14881. */
  14882. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14883. /**
  14884. * Adds a new ramp gradient used to remap particle colors
  14885. * @param gradient defines the gradient to use (between 0 and 1)
  14886. * @param color defines the color to affect to the specified gradient
  14887. * @returns the current particle system
  14888. */
  14889. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  14890. /**
  14891. * Remove a specific ramp gradient
  14892. * @param gradient defines the gradient to remove
  14893. * @returns the current particle system
  14894. */
  14895. removeRampGradient(gradient: number): ParticleSystem;
  14896. /**
  14897. * Adds a new color gradient
  14898. * @param gradient defines the gradient to use (between 0 and 1)
  14899. * @param color1 defines the color to affect to the specified gradient
  14900. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14901. * @returns this particle system
  14902. */
  14903. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14904. /**
  14905. * Remove a specific color gradient
  14906. * @param gradient defines the gradient to remove
  14907. * @returns this particle system
  14908. */
  14909. removeColorGradient(gradient: number): IParticleSystem;
  14910. private _fetchR;
  14911. protected _reset(): void;
  14912. private _resetEffect;
  14913. private _createVertexBuffers;
  14914. private _createIndexBuffer;
  14915. /**
  14916. * Gets the maximum number of particles active at the same time.
  14917. * @returns The max number of active particles.
  14918. */
  14919. getCapacity(): number;
  14920. /**
  14921. * Gets whether there are still active particles in the system.
  14922. * @returns True if it is alive, otherwise false.
  14923. */
  14924. isAlive(): boolean;
  14925. /**
  14926. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14927. * @returns True if it has been started, otherwise false.
  14928. */
  14929. isStarted(): boolean;
  14930. private _prepareSubEmitterInternalArray;
  14931. /**
  14932. * Starts the particle system and begins to emit
  14933. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  14934. */
  14935. start(delay?: number): void;
  14936. /**
  14937. * Stops the particle system.
  14938. * @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.
  14939. */
  14940. stop(stopSubEmitters?: boolean): void;
  14941. /**
  14942. * Remove all active particles
  14943. */
  14944. reset(): void;
  14945. /**
  14946. * @hidden (for internal use only)
  14947. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14948. /**
  14949. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14950. * Its lifetime will start back at 0.
  14951. */
  14952. recycleParticle: (particle: Particle) => void;
  14953. private _stopSubEmitters;
  14954. private _createParticle;
  14955. private _removeFromRoot;
  14956. private _emitFromParticle;
  14957. private _update;
  14958. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  14959. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  14960. /** @hidden */
  14961. private _getEffect;
  14962. /**
  14963. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14964. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  14965. */
  14966. animate(preWarmOnly?: boolean): void;
  14967. private _appendParticleVertices;
  14968. /**
  14969. * Rebuilds the particle system.
  14970. */
  14971. rebuild(): void;
  14972. /**
  14973. * Is this system ready to be used/rendered
  14974. * @return true if the system is ready
  14975. */
  14976. isReady(): boolean;
  14977. private _render;
  14978. /**
  14979. * Renders the particle system in its current state.
  14980. * @returns the current number of particles
  14981. */
  14982. render(): number;
  14983. /**
  14984. * Disposes the particle system and free the associated resources
  14985. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14986. */
  14987. dispose(disposeTexture?: boolean): void;
  14988. /**
  14989. * Clones the particle system.
  14990. * @param name The name of the cloned object
  14991. * @param newEmitter The new emitter to use
  14992. * @returns the cloned particle system
  14993. */
  14994. clone(name: string, newEmitter: any): ParticleSystem;
  14995. /**
  14996. * Serializes the particle system to a JSON object.
  14997. * @returns the JSON object
  14998. */
  14999. serialize(): any;
  15000. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15001. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15002. /**
  15003. * Parses a JSON object to create a particle system.
  15004. * @param parsedParticleSystem The JSON object to parse
  15005. * @param scene The scene to create the particle system in
  15006. * @param rootUrl The root url to use to load external dependencies like texture
  15007. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15008. * @returns the Parsed particle system
  15009. */
  15010. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15011. }
  15012. }
  15013. declare module BABYLON {
  15014. /**
  15015. * A particle represents one of the element emitted by a particle system.
  15016. * This is mainly define by its coordinates, direction, velocity and age.
  15017. */
  15018. export class Particle {
  15019. /**
  15020. * The particle system the particle belongs to.
  15021. */
  15022. particleSystem: ParticleSystem;
  15023. private static _Count;
  15024. /**
  15025. * Unique ID of the particle
  15026. */
  15027. id: number;
  15028. /**
  15029. * The world position of the particle in the scene.
  15030. */
  15031. position: Vector3;
  15032. /**
  15033. * The world direction of the particle in the scene.
  15034. */
  15035. direction: Vector3;
  15036. /**
  15037. * The color of the particle.
  15038. */
  15039. color: Color4;
  15040. /**
  15041. * The color change of the particle per step.
  15042. */
  15043. colorStep: Color4;
  15044. /**
  15045. * Defines how long will the life of the particle be.
  15046. */
  15047. lifeTime: number;
  15048. /**
  15049. * The current age of the particle.
  15050. */
  15051. age: number;
  15052. /**
  15053. * The current size of the particle.
  15054. */
  15055. size: number;
  15056. /**
  15057. * The current scale of the particle.
  15058. */
  15059. scale: Vector2;
  15060. /**
  15061. * The current angle of the particle.
  15062. */
  15063. angle: number;
  15064. /**
  15065. * Defines how fast is the angle changing.
  15066. */
  15067. angularSpeed: number;
  15068. /**
  15069. * Defines the cell index used by the particle to be rendered from a sprite.
  15070. */
  15071. cellIndex: number;
  15072. /**
  15073. * The information required to support color remapping
  15074. */
  15075. remapData: Vector4;
  15076. /** @hidden */ private _randomCellOffset?: number;
  15077. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  15078. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15079. /** @hidden */ private _initialStartSpriteCellID: number;
  15080. /** @hidden */ private _initialEndSpriteCellID: number;
  15081. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  15082. /** @hidden */ private _currentColor1: Color4;
  15083. /** @hidden */ private _currentColor2: Color4;
  15084. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  15085. /** @hidden */ private _currentSize1: number;
  15086. /** @hidden */ private _currentSize2: number;
  15087. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15088. /** @hidden */ private _currentAngularSpeed1: number;
  15089. /** @hidden */ private _currentAngularSpeed2: number;
  15090. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  15091. /** @hidden */ private _currentVelocity1: number;
  15092. /** @hidden */ private _currentVelocity2: number;
  15093. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15094. /** @hidden */ private _currentLimitVelocity1: number;
  15095. /** @hidden */ private _currentLimitVelocity2: number;
  15096. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  15097. /** @hidden */ private _currentDrag1: number;
  15098. /** @hidden */ private _currentDrag2: number;
  15099. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  15100. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  15101. /**
  15102. * Creates a new instance Particle
  15103. * @param particleSystem the particle system the particle belongs to
  15104. */
  15105. constructor(
  15106. /**
  15107. * The particle system the particle belongs to.
  15108. */
  15109. particleSystem: ParticleSystem);
  15110. private updateCellInfoFromSystem;
  15111. /**
  15112. * Defines how the sprite cell index is updated for the particle
  15113. */
  15114. updateCellIndex(): void;
  15115. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15116. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  15117. /** @hidden */ private _reset(): void;
  15118. /**
  15119. * Copy the properties of particle to another one.
  15120. * @param other the particle to copy the information to.
  15121. */
  15122. copyTo(other: Particle): void;
  15123. }
  15124. }
  15125. declare module BABYLON {
  15126. /**
  15127. * Particle emitter represents a volume emitting particles.
  15128. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15129. */
  15130. export interface IParticleEmitterType {
  15131. /**
  15132. * Called by the particle System when the direction is computed for the created particle.
  15133. * @param worldMatrix is the world matrix of the particle system
  15134. * @param directionToUpdate is the direction vector to update with the result
  15135. * @param particle is the particle we are computed the direction for
  15136. */
  15137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15138. /**
  15139. * Called by the particle System when the position is computed for the created particle.
  15140. * @param worldMatrix is the world matrix of the particle system
  15141. * @param positionToUpdate is the position vector to update with the result
  15142. * @param particle is the particle we are computed the position for
  15143. */
  15144. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15145. /**
  15146. * Clones the current emitter and returns a copy of it
  15147. * @returns the new emitter
  15148. */
  15149. clone(): IParticleEmitterType;
  15150. /**
  15151. * Called by the GPUParticleSystem to setup the update shader
  15152. * @param effect defines the update shader
  15153. */
  15154. applyToShader(effect: Effect): void;
  15155. /**
  15156. * Returns a string to use to update the GPU particles update shader
  15157. * @returns the effect defines string
  15158. */
  15159. getEffectDefines(): string;
  15160. /**
  15161. * Returns a string representing the class name
  15162. * @returns a string containing the class name
  15163. */
  15164. getClassName(): string;
  15165. /**
  15166. * Serializes the particle system to a JSON object.
  15167. * @returns the JSON object
  15168. */
  15169. serialize(): any;
  15170. /**
  15171. * Parse properties from a JSON object
  15172. * @param serializationObject defines the JSON object
  15173. */
  15174. parse(serializationObject: any): void;
  15175. }
  15176. }
  15177. declare module BABYLON {
  15178. /**
  15179. * Particle emitter emitting particles from the inside of a box.
  15180. * It emits the particles randomly between 2 given directions.
  15181. */
  15182. export class BoxParticleEmitter implements IParticleEmitterType {
  15183. /**
  15184. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15185. */
  15186. direction1: Vector3;
  15187. /**
  15188. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15189. */
  15190. direction2: Vector3;
  15191. /**
  15192. * 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.
  15193. */
  15194. minEmitBox: Vector3;
  15195. /**
  15196. * 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.
  15197. */
  15198. maxEmitBox: Vector3;
  15199. /**
  15200. * Creates a new instance BoxParticleEmitter
  15201. */
  15202. constructor();
  15203. /**
  15204. * Called by the particle System when the direction is computed for the created particle.
  15205. * @param worldMatrix is the world matrix of the particle system
  15206. * @param directionToUpdate is the direction vector to update with the result
  15207. * @param particle is the particle we are computed the direction for
  15208. */
  15209. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15210. /**
  15211. * Called by the particle System when the position is computed for the created particle.
  15212. * @param worldMatrix is the world matrix of the particle system
  15213. * @param positionToUpdate is the position vector to update with the result
  15214. * @param particle is the particle we are computed the position for
  15215. */
  15216. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15217. /**
  15218. * Clones the current emitter and returns a copy of it
  15219. * @returns the new emitter
  15220. */
  15221. clone(): BoxParticleEmitter;
  15222. /**
  15223. * Called by the GPUParticleSystem to setup the update shader
  15224. * @param effect defines the update shader
  15225. */
  15226. applyToShader(effect: Effect): void;
  15227. /**
  15228. * Returns a string to use to update the GPU particles update shader
  15229. * @returns a string containng the defines string
  15230. */
  15231. getEffectDefines(): string;
  15232. /**
  15233. * Returns the string "BoxParticleEmitter"
  15234. * @returns a string containing the class name
  15235. */
  15236. getClassName(): string;
  15237. /**
  15238. * Serializes the particle system to a JSON object.
  15239. * @returns the JSON object
  15240. */
  15241. serialize(): any;
  15242. /**
  15243. * Parse properties from a JSON object
  15244. * @param serializationObject defines the JSON object
  15245. */
  15246. parse(serializationObject: any): void;
  15247. }
  15248. }
  15249. declare module BABYLON {
  15250. /**
  15251. * Particle emitter emitting particles from the inside of a cone.
  15252. * It emits the particles alongside the cone volume from the base to the particle.
  15253. * The emission direction might be randomized.
  15254. */
  15255. export class ConeParticleEmitter implements IParticleEmitterType {
  15256. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15257. directionRandomizer: number;
  15258. private _radius;
  15259. private _angle;
  15260. private _height;
  15261. /**
  15262. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15263. */
  15264. radiusRange: number;
  15265. /**
  15266. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15267. */
  15268. heightRange: number;
  15269. /**
  15270. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15271. */
  15272. emitFromSpawnPointOnly: boolean;
  15273. /**
  15274. * Gets or sets the radius of the emission cone
  15275. */
  15276. radius: number;
  15277. /**
  15278. * Gets or sets the angle of the emission cone
  15279. */
  15280. angle: number;
  15281. private _buildHeight;
  15282. /**
  15283. * Creates a new instance ConeParticleEmitter
  15284. * @param radius the radius of the emission cone (1 by default)
  15285. * @param angle the cone base angle (PI by default)
  15286. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15287. */
  15288. constructor(radius?: number, angle?: number,
  15289. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15290. directionRandomizer?: number);
  15291. /**
  15292. * Called by the particle System when the direction is computed for the created particle.
  15293. * @param worldMatrix is the world matrix of the particle system
  15294. * @param directionToUpdate is the direction vector to update with the result
  15295. * @param particle is the particle we are computed the direction for
  15296. */
  15297. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15298. /**
  15299. * Called by the particle System when the position is computed for the created particle.
  15300. * @param worldMatrix is the world matrix of the particle system
  15301. * @param positionToUpdate is the position vector to update with the result
  15302. * @param particle is the particle we are computed the position for
  15303. */
  15304. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15305. /**
  15306. * Clones the current emitter and returns a copy of it
  15307. * @returns the new emitter
  15308. */
  15309. clone(): ConeParticleEmitter;
  15310. /**
  15311. * Called by the GPUParticleSystem to setup the update shader
  15312. * @param effect defines the update shader
  15313. */
  15314. applyToShader(effect: Effect): void;
  15315. /**
  15316. * Returns a string to use to update the GPU particles update shader
  15317. * @returns a string containng the defines string
  15318. */
  15319. getEffectDefines(): string;
  15320. /**
  15321. * Returns the string "ConeParticleEmitter"
  15322. * @returns a string containing the class name
  15323. */
  15324. getClassName(): string;
  15325. /**
  15326. * Serializes the particle system to a JSON object.
  15327. * @returns the JSON object
  15328. */
  15329. serialize(): any;
  15330. /**
  15331. * Parse properties from a JSON object
  15332. * @param serializationObject defines the JSON object
  15333. */
  15334. parse(serializationObject: any): void;
  15335. }
  15336. }
  15337. declare module BABYLON {
  15338. /**
  15339. * Particle emitter emitting particles from the inside of a cylinder.
  15340. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15341. */
  15342. export class CylinderParticleEmitter implements IParticleEmitterType {
  15343. /**
  15344. * The radius of the emission cylinder.
  15345. */
  15346. radius: number;
  15347. /**
  15348. * The height of the emission cylinder.
  15349. */
  15350. height: number;
  15351. /**
  15352. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15353. */
  15354. radiusRange: number;
  15355. /**
  15356. * How much to randomize the particle direction [0-1].
  15357. */
  15358. directionRandomizer: number;
  15359. /**
  15360. * Creates a new instance CylinderParticleEmitter
  15361. * @param radius the radius of the emission cylinder (1 by default)
  15362. * @param height the height of the emission cylinder (1 by default)
  15363. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15364. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15365. */
  15366. constructor(
  15367. /**
  15368. * The radius of the emission cylinder.
  15369. */
  15370. radius?: number,
  15371. /**
  15372. * The height of the emission cylinder.
  15373. */
  15374. height?: number,
  15375. /**
  15376. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15377. */
  15378. radiusRange?: number,
  15379. /**
  15380. * How much to randomize the particle direction [0-1].
  15381. */
  15382. directionRandomizer?: number);
  15383. /**
  15384. * Called by the particle System when the direction is computed for the created particle.
  15385. * @param worldMatrix is the world matrix of the particle system
  15386. * @param directionToUpdate is the direction vector to update with the result
  15387. * @param particle is the particle we are computed the direction for
  15388. */
  15389. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15390. /**
  15391. * Called by the particle System when the position is computed for the created particle.
  15392. * @param worldMatrix is the world matrix of the particle system
  15393. * @param positionToUpdate is the position vector to update with the result
  15394. * @param particle is the particle we are computed the position for
  15395. */
  15396. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15397. /**
  15398. * Clones the current emitter and returns a copy of it
  15399. * @returns the new emitter
  15400. */
  15401. clone(): CylinderParticleEmitter;
  15402. /**
  15403. * Called by the GPUParticleSystem to setup the update shader
  15404. * @param effect defines the update shader
  15405. */
  15406. applyToShader(effect: Effect): void;
  15407. /**
  15408. * Returns a string to use to update the GPU particles update shader
  15409. * @returns a string containng the defines string
  15410. */
  15411. getEffectDefines(): string;
  15412. /**
  15413. * Returns the string "CylinderParticleEmitter"
  15414. * @returns a string containing the class name
  15415. */
  15416. getClassName(): string;
  15417. /**
  15418. * Serializes the particle system to a JSON object.
  15419. * @returns the JSON object
  15420. */
  15421. serialize(): any;
  15422. /**
  15423. * Parse properties from a JSON object
  15424. * @param serializationObject defines the JSON object
  15425. */
  15426. parse(serializationObject: any): void;
  15427. }
  15428. /**
  15429. * Particle emitter emitting particles from the inside of a cylinder.
  15430. * It emits the particles randomly between two vectors.
  15431. */
  15432. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15433. /**
  15434. * The min limit of the emission direction.
  15435. */
  15436. direction1: Vector3;
  15437. /**
  15438. * The max limit of the emission direction.
  15439. */
  15440. direction2: Vector3;
  15441. /**
  15442. * Creates a new instance CylinderDirectedParticleEmitter
  15443. * @param radius the radius of the emission cylinder (1 by default)
  15444. * @param height the height of the emission cylinder (1 by default)
  15445. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15446. * @param direction1 the min limit of the emission direction (up vector by default)
  15447. * @param direction2 the max limit of the emission direction (up vector by default)
  15448. */
  15449. constructor(radius?: number, height?: number, radiusRange?: number,
  15450. /**
  15451. * The min limit of the emission direction.
  15452. */
  15453. direction1?: Vector3,
  15454. /**
  15455. * The max limit of the emission direction.
  15456. */
  15457. direction2?: Vector3);
  15458. /**
  15459. * Called by the particle System when the direction is computed for the created particle.
  15460. * @param worldMatrix is the world matrix of the particle system
  15461. * @param directionToUpdate is the direction vector to update with the result
  15462. * @param particle is the particle we are computed the direction for
  15463. */
  15464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15465. /**
  15466. * Clones the current emitter and returns a copy of it
  15467. * @returns the new emitter
  15468. */
  15469. clone(): CylinderDirectedParticleEmitter;
  15470. /**
  15471. * Called by the GPUParticleSystem to setup the update shader
  15472. * @param effect defines the update shader
  15473. */
  15474. applyToShader(effect: Effect): void;
  15475. /**
  15476. * Returns a string to use to update the GPU particles update shader
  15477. * @returns a string containng the defines string
  15478. */
  15479. getEffectDefines(): string;
  15480. /**
  15481. * Returns the string "CylinderDirectedParticleEmitter"
  15482. * @returns a string containing the class name
  15483. */
  15484. getClassName(): string;
  15485. /**
  15486. * Serializes the particle system to a JSON object.
  15487. * @returns the JSON object
  15488. */
  15489. serialize(): any;
  15490. /**
  15491. * Parse properties from a JSON object
  15492. * @param serializationObject defines the JSON object
  15493. */
  15494. parse(serializationObject: any): void;
  15495. }
  15496. }
  15497. declare module BABYLON {
  15498. /**
  15499. * Particle emitter emitting particles from the inside of a hemisphere.
  15500. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15501. */
  15502. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15503. /**
  15504. * The radius of the emission hemisphere.
  15505. */
  15506. radius: number;
  15507. /**
  15508. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15509. */
  15510. radiusRange: number;
  15511. /**
  15512. * How much to randomize the particle direction [0-1].
  15513. */
  15514. directionRandomizer: number;
  15515. /**
  15516. * Creates a new instance HemisphericParticleEmitter
  15517. * @param radius the radius of the emission hemisphere (1 by default)
  15518. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15519. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15520. */
  15521. constructor(
  15522. /**
  15523. * The radius of the emission hemisphere.
  15524. */
  15525. radius?: number,
  15526. /**
  15527. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15528. */
  15529. radiusRange?: number,
  15530. /**
  15531. * How much to randomize the particle direction [0-1].
  15532. */
  15533. directionRandomizer?: number);
  15534. /**
  15535. * Called by the particle System when the direction is computed for the created particle.
  15536. * @param worldMatrix is the world matrix of the particle system
  15537. * @param directionToUpdate is the direction vector to update with the result
  15538. * @param particle is the particle we are computed the direction for
  15539. */
  15540. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15541. /**
  15542. * Called by the particle System when the position is computed for the created particle.
  15543. * @param worldMatrix is the world matrix of the particle system
  15544. * @param positionToUpdate is the position vector to update with the result
  15545. * @param particle is the particle we are computed the position for
  15546. */
  15547. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15548. /**
  15549. * Clones the current emitter and returns a copy of it
  15550. * @returns the new emitter
  15551. */
  15552. clone(): HemisphericParticleEmitter;
  15553. /**
  15554. * Called by the GPUParticleSystem to setup the update shader
  15555. * @param effect defines the update shader
  15556. */
  15557. applyToShader(effect: Effect): void;
  15558. /**
  15559. * Returns a string to use to update the GPU particles update shader
  15560. * @returns a string containng the defines string
  15561. */
  15562. getEffectDefines(): string;
  15563. /**
  15564. * Returns the string "HemisphericParticleEmitter"
  15565. * @returns a string containing the class name
  15566. */
  15567. getClassName(): string;
  15568. /**
  15569. * Serializes the particle system to a JSON object.
  15570. * @returns the JSON object
  15571. */
  15572. serialize(): any;
  15573. /**
  15574. * Parse properties from a JSON object
  15575. * @param serializationObject defines the JSON object
  15576. */
  15577. parse(serializationObject: any): void;
  15578. }
  15579. }
  15580. declare module BABYLON {
  15581. /**
  15582. * Particle emitter emitting particles from a point.
  15583. * It emits the particles randomly between 2 given directions.
  15584. */
  15585. export class PointParticleEmitter implements IParticleEmitterType {
  15586. /**
  15587. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15588. */
  15589. direction1: Vector3;
  15590. /**
  15591. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15592. */
  15593. direction2: Vector3;
  15594. /**
  15595. * Creates a new instance PointParticleEmitter
  15596. */
  15597. constructor();
  15598. /**
  15599. * Called by the particle System when the direction is computed for the created particle.
  15600. * @param worldMatrix is the world matrix of the particle system
  15601. * @param directionToUpdate is the direction vector to update with the result
  15602. * @param particle is the particle we are computed the direction for
  15603. */
  15604. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15605. /**
  15606. * Called by the particle System when the position is computed for the created particle.
  15607. * @param worldMatrix is the world matrix of the particle system
  15608. * @param positionToUpdate is the position vector to update with the result
  15609. * @param particle is the particle we are computed the position for
  15610. */
  15611. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15612. /**
  15613. * Clones the current emitter and returns a copy of it
  15614. * @returns the new emitter
  15615. */
  15616. clone(): PointParticleEmitter;
  15617. /**
  15618. * Called by the GPUParticleSystem to setup the update shader
  15619. * @param effect defines the update shader
  15620. */
  15621. applyToShader(effect: Effect): void;
  15622. /**
  15623. * Returns a string to use to update the GPU particles update shader
  15624. * @returns a string containng the defines string
  15625. */
  15626. getEffectDefines(): string;
  15627. /**
  15628. * Returns the string "PointParticleEmitter"
  15629. * @returns a string containing the class name
  15630. */
  15631. getClassName(): string;
  15632. /**
  15633. * Serializes the particle system to a JSON object.
  15634. * @returns the JSON object
  15635. */
  15636. serialize(): any;
  15637. /**
  15638. * Parse properties from a JSON object
  15639. * @param serializationObject defines the JSON object
  15640. */
  15641. parse(serializationObject: any): void;
  15642. }
  15643. }
  15644. declare module BABYLON {
  15645. /**
  15646. * Particle emitter emitting particles from the inside of a sphere.
  15647. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  15648. */
  15649. export class SphereParticleEmitter implements IParticleEmitterType {
  15650. /**
  15651. * The radius of the emission sphere.
  15652. */
  15653. radius: number;
  15654. /**
  15655. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15656. */
  15657. radiusRange: number;
  15658. /**
  15659. * How much to randomize the particle direction [0-1].
  15660. */
  15661. directionRandomizer: number;
  15662. /**
  15663. * Creates a new instance SphereParticleEmitter
  15664. * @param radius the radius of the emission sphere (1 by default)
  15665. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15666. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15667. */
  15668. constructor(
  15669. /**
  15670. * The radius of the emission sphere.
  15671. */
  15672. radius?: number,
  15673. /**
  15674. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15675. */
  15676. radiusRange?: number,
  15677. /**
  15678. * How much to randomize the particle direction [0-1].
  15679. */
  15680. directionRandomizer?: number);
  15681. /**
  15682. * Called by the particle System when the direction is computed for the created particle.
  15683. * @param worldMatrix is the world matrix of the particle system
  15684. * @param directionToUpdate is the direction vector to update with the result
  15685. * @param particle is the particle we are computed the direction for
  15686. */
  15687. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15688. /**
  15689. * Called by the particle System when the position is computed for the created particle.
  15690. * @param worldMatrix is the world matrix of the particle system
  15691. * @param positionToUpdate is the position vector to update with the result
  15692. * @param particle is the particle we are computed the position for
  15693. */
  15694. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15695. /**
  15696. * Clones the current emitter and returns a copy of it
  15697. * @returns the new emitter
  15698. */
  15699. clone(): SphereParticleEmitter;
  15700. /**
  15701. * Called by the GPUParticleSystem to setup the update shader
  15702. * @param effect defines the update shader
  15703. */
  15704. applyToShader(effect: Effect): void;
  15705. /**
  15706. * Returns a string to use to update the GPU particles update shader
  15707. * @returns a string containng the defines string
  15708. */
  15709. getEffectDefines(): string;
  15710. /**
  15711. * Returns the string "SphereParticleEmitter"
  15712. * @returns a string containing the class name
  15713. */
  15714. getClassName(): string;
  15715. /**
  15716. * Serializes the particle system to a JSON object.
  15717. * @returns the JSON object
  15718. */
  15719. serialize(): any;
  15720. /**
  15721. * Parse properties from a JSON object
  15722. * @param serializationObject defines the JSON object
  15723. */
  15724. parse(serializationObject: any): void;
  15725. }
  15726. /**
  15727. * Particle emitter emitting particles from the inside of a sphere.
  15728. * It emits the particles randomly between two vectors.
  15729. */
  15730. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  15731. /**
  15732. * The min limit of the emission direction.
  15733. */
  15734. direction1: Vector3;
  15735. /**
  15736. * The max limit of the emission direction.
  15737. */
  15738. direction2: Vector3;
  15739. /**
  15740. * Creates a new instance SphereDirectedParticleEmitter
  15741. * @param radius the radius of the emission sphere (1 by default)
  15742. * @param direction1 the min limit of the emission direction (up vector by default)
  15743. * @param direction2 the max limit of the emission direction (up vector by default)
  15744. */
  15745. constructor(radius?: number,
  15746. /**
  15747. * The min limit of the emission direction.
  15748. */
  15749. direction1?: Vector3,
  15750. /**
  15751. * The max limit of the emission direction.
  15752. */
  15753. direction2?: Vector3);
  15754. /**
  15755. * Called by the particle System when the direction is computed for the created particle.
  15756. * @param worldMatrix is the world matrix of the particle system
  15757. * @param directionToUpdate is the direction vector to update with the result
  15758. * @param particle is the particle we are computed the direction for
  15759. */
  15760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15761. /**
  15762. * Clones the current emitter and returns a copy of it
  15763. * @returns the new emitter
  15764. */
  15765. clone(): SphereDirectedParticleEmitter;
  15766. /**
  15767. * Called by the GPUParticleSystem to setup the update shader
  15768. * @param effect defines the update shader
  15769. */
  15770. applyToShader(effect: Effect): void;
  15771. /**
  15772. * Returns a string to use to update the GPU particles update shader
  15773. * @returns a string containng the defines string
  15774. */
  15775. getEffectDefines(): string;
  15776. /**
  15777. * Returns the string "SphereDirectedParticleEmitter"
  15778. * @returns a string containing the class name
  15779. */
  15780. getClassName(): string;
  15781. /**
  15782. * Serializes the particle system to a JSON object.
  15783. * @returns the JSON object
  15784. */
  15785. serialize(): any;
  15786. /**
  15787. * Parse properties from a JSON object
  15788. * @param serializationObject defines the JSON object
  15789. */
  15790. parse(serializationObject: any): void;
  15791. }
  15792. }
  15793. declare module BABYLON {
  15794. /**
  15795. * Interface representing a particle system in Babylon.js.
  15796. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  15797. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  15798. */
  15799. export interface IParticleSystem {
  15800. /**
  15801. * List of animations used by the particle system.
  15802. */
  15803. animations: Animation[];
  15804. /**
  15805. * The id of the Particle system.
  15806. */
  15807. id: string;
  15808. /**
  15809. * The name of the Particle system.
  15810. */
  15811. name: string;
  15812. /**
  15813. * The emitter represents the Mesh or position we are attaching the particle system to.
  15814. */
  15815. emitter: Nullable<AbstractMesh | Vector3>;
  15816. /**
  15817. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  15818. */
  15819. isBillboardBased: boolean;
  15820. /**
  15821. * The rendering group used by the Particle system to chose when to render.
  15822. */
  15823. renderingGroupId: number;
  15824. /**
  15825. * The layer mask we are rendering the particles through.
  15826. */
  15827. layerMask: number;
  15828. /**
  15829. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  15830. */
  15831. updateSpeed: number;
  15832. /**
  15833. * The amount of time the particle system is running (depends of the overall update speed).
  15834. */
  15835. targetStopDuration: number;
  15836. /**
  15837. * The texture used to render each particle. (this can be a spritesheet)
  15838. */
  15839. particleTexture: Nullable<Texture>;
  15840. /**
  15841. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  15842. */
  15843. blendMode: number;
  15844. /**
  15845. * Minimum life time of emitting particles.
  15846. */
  15847. minLifeTime: number;
  15848. /**
  15849. * Maximum life time of emitting particles.
  15850. */
  15851. maxLifeTime: number;
  15852. /**
  15853. * Minimum Size of emitting particles.
  15854. */
  15855. minSize: number;
  15856. /**
  15857. * Maximum Size of emitting particles.
  15858. */
  15859. maxSize: number;
  15860. /**
  15861. * Minimum scale of emitting particles on X axis.
  15862. */
  15863. minScaleX: number;
  15864. /**
  15865. * Maximum scale of emitting particles on X axis.
  15866. */
  15867. maxScaleX: number;
  15868. /**
  15869. * Minimum scale of emitting particles on Y axis.
  15870. */
  15871. minScaleY: number;
  15872. /**
  15873. * Maximum scale of emitting particles on Y axis.
  15874. */
  15875. maxScaleY: number;
  15876. /**
  15877. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15878. */
  15879. color1: Color4;
  15880. /**
  15881. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  15882. */
  15883. color2: Color4;
  15884. /**
  15885. * Color the particle will have at the end of its lifetime.
  15886. */
  15887. colorDead: Color4;
  15888. /**
  15889. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  15890. */
  15891. emitRate: number;
  15892. /**
  15893. * You can use gravity if you want to give an orientation to your particles.
  15894. */
  15895. gravity: Vector3;
  15896. /**
  15897. * Minimum power of emitting particles.
  15898. */
  15899. minEmitPower: number;
  15900. /**
  15901. * Maximum power of emitting particles.
  15902. */
  15903. maxEmitPower: number;
  15904. /**
  15905. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  15906. */
  15907. minAngularSpeed: number;
  15908. /**
  15909. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  15910. */
  15911. maxAngularSpeed: number;
  15912. /**
  15913. * Gets or sets the minimal initial rotation in radians.
  15914. */
  15915. minInitialRotation: number;
  15916. /**
  15917. * Gets or sets the maximal initial rotation in radians.
  15918. */
  15919. maxInitialRotation: number;
  15920. /**
  15921. * The particle emitter type defines the emitter used by the particle system.
  15922. * It can be for example box, sphere, or cone...
  15923. */
  15924. particleEmitterType: Nullable<IParticleEmitterType>;
  15925. /**
  15926. * Defines the delay in milliseconds before starting the system (0 by default)
  15927. */
  15928. startDelay: number;
  15929. /**
  15930. * 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
  15931. */
  15932. preWarmCycles: number;
  15933. /**
  15934. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  15935. */
  15936. preWarmStepOffset: number;
  15937. /**
  15938. * 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)
  15939. */
  15940. spriteCellChangeSpeed: number;
  15941. /**
  15942. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  15943. */
  15944. startSpriteCellID: number;
  15945. /**
  15946. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  15947. */
  15948. endSpriteCellID: number;
  15949. /**
  15950. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  15951. */
  15952. spriteCellWidth: number;
  15953. /**
  15954. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  15955. */
  15956. spriteCellHeight: number;
  15957. /**
  15958. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  15959. */
  15960. spriteRandomStartCell: boolean;
  15961. /**
  15962. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  15963. */
  15964. isAnimationSheetEnabled: boolean;
  15965. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  15966. translationPivot: Vector2;
  15967. /**
  15968. * Gets or sets a texture used to add random noise to particle positions
  15969. */
  15970. noiseTexture: Nullable<BaseTexture>;
  15971. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  15972. noiseStrength: Vector3;
  15973. /**
  15974. * Gets or sets the billboard mode to use when isBillboardBased = true.
  15975. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  15976. */
  15977. billboardMode: number;
  15978. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  15979. limitVelocityDamping: number;
  15980. /**
  15981. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  15982. */
  15983. beginAnimationOnStart: boolean;
  15984. /**
  15985. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  15986. */
  15987. beginAnimationFrom: number;
  15988. /**
  15989. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  15990. */
  15991. beginAnimationTo: number;
  15992. /**
  15993. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  15994. */
  15995. beginAnimationLoop: boolean;
  15996. /**
  15997. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  15998. */
  15999. disposeOnStop: boolean;
  16000. /**
  16001. * Gets the maximum number of particles active at the same time.
  16002. * @returns The max number of active particles.
  16003. */
  16004. getCapacity(): number;
  16005. /**
  16006. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16007. * @returns True if it has been started, otherwise false.
  16008. */
  16009. isStarted(): boolean;
  16010. /**
  16011. * Animates the particle system for this frame.
  16012. */
  16013. animate(): void;
  16014. /**
  16015. * Renders the particle system in its current state.
  16016. * @returns the current number of particles
  16017. */
  16018. render(): number;
  16019. /**
  16020. * Dispose the particle system and frees its associated resources.
  16021. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16022. */
  16023. dispose(disposeTexture?: boolean): void;
  16024. /**
  16025. * Clones the particle system.
  16026. * @param name The name of the cloned object
  16027. * @param newEmitter The new emitter to use
  16028. * @returns the cloned particle system
  16029. */
  16030. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16031. /**
  16032. * Serializes the particle system to a JSON object.
  16033. * @returns the JSON object
  16034. */
  16035. serialize(): any;
  16036. /**
  16037. * Rebuild the particle system
  16038. */
  16039. rebuild(): void;
  16040. /**
  16041. * Starts the particle system and begins to emit
  16042. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16043. */
  16044. start(delay?: number): void;
  16045. /**
  16046. * Stops the particle system.
  16047. */
  16048. stop(): void;
  16049. /**
  16050. * Remove all active particles
  16051. */
  16052. reset(): void;
  16053. /**
  16054. * Is this system ready to be used/rendered
  16055. * @return true if the system is ready
  16056. */
  16057. isReady(): boolean;
  16058. /**
  16059. * Adds a new color gradient
  16060. * @param gradient defines the gradient to use (between 0 and 1)
  16061. * @param color1 defines the color to affect to the specified gradient
  16062. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16063. * @returns the current particle system
  16064. */
  16065. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16066. /**
  16067. * Remove a specific color gradient
  16068. * @param gradient defines the gradient to remove
  16069. * @returns the current particle system
  16070. */
  16071. removeColorGradient(gradient: number): IParticleSystem;
  16072. /**
  16073. * Adds a new size gradient
  16074. * @param gradient defines the gradient to use (between 0 and 1)
  16075. * @param factor defines the size factor to affect to the specified gradient
  16076. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16077. * @returns the current particle system
  16078. */
  16079. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16080. /**
  16081. * Remove a specific size gradient
  16082. * @param gradient defines the gradient to remove
  16083. * @returns the current particle system
  16084. */
  16085. removeSizeGradient(gradient: number): IParticleSystem;
  16086. /**
  16087. * Gets the current list of color gradients.
  16088. * You must use addColorGradient and removeColorGradient to udpate this list
  16089. * @returns the list of color gradients
  16090. */
  16091. getColorGradients(): Nullable<Array<ColorGradient>>;
  16092. /**
  16093. * Gets the current list of size gradients.
  16094. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16095. * @returns the list of size gradients
  16096. */
  16097. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16098. /**
  16099. * Gets the current list of angular speed gradients.
  16100. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16101. * @returns the list of angular speed gradients
  16102. */
  16103. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16104. /**
  16105. * Adds a new angular speed gradient
  16106. * @param gradient defines the gradient to use (between 0 and 1)
  16107. * @param factor defines the angular speed to affect to the specified gradient
  16108. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16109. * @returns the current particle system
  16110. */
  16111. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16112. /**
  16113. * Remove a specific angular speed gradient
  16114. * @param gradient defines the gradient to remove
  16115. * @returns the current particle system
  16116. */
  16117. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16118. /**
  16119. * Gets the current list of velocity gradients.
  16120. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16121. * @returns the list of velocity gradients
  16122. */
  16123. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16124. /**
  16125. * Adds a new velocity gradient
  16126. * @param gradient defines the gradient to use (between 0 and 1)
  16127. * @param factor defines the velocity to affect to the specified gradient
  16128. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16129. * @returns the current particle system
  16130. */
  16131. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16132. /**
  16133. * Remove a specific velocity gradient
  16134. * @param gradient defines the gradient to remove
  16135. * @returns the current particle system
  16136. */
  16137. removeVelocityGradient(gradient: number): IParticleSystem;
  16138. /**
  16139. * Gets the current list of limit velocity gradients.
  16140. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16141. * @returns the list of limit velocity gradients
  16142. */
  16143. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16144. /**
  16145. * Adds a new limit velocity gradient
  16146. * @param gradient defines the gradient to use (between 0 and 1)
  16147. * @param factor defines the limit velocity to affect to the specified gradient
  16148. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16149. * @returns the current particle system
  16150. */
  16151. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16152. /**
  16153. * Remove a specific limit velocity gradient
  16154. * @param gradient defines the gradient to remove
  16155. * @returns the current particle system
  16156. */
  16157. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16158. /**
  16159. * Adds a new drag gradient
  16160. * @param gradient defines the gradient to use (between 0 and 1)
  16161. * @param factor defines the drag to affect to the specified gradient
  16162. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16163. * @returns the current particle system
  16164. */
  16165. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16166. /**
  16167. * Remove a specific drag gradient
  16168. * @param gradient defines the gradient to remove
  16169. * @returns the current particle system
  16170. */
  16171. removeDragGradient(gradient: number): IParticleSystem;
  16172. /**
  16173. * Gets the current list of drag gradients.
  16174. * You must use addDragGradient and removeDragGradient to udpate this list
  16175. * @returns the list of drag gradients
  16176. */
  16177. getDragGradients(): Nullable<Array<FactorGradient>>;
  16178. /**
  16179. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16180. * @param gradient defines the gradient to use (between 0 and 1)
  16181. * @param factor defines the emit rate to affect to the specified gradient
  16182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16183. * @returns the current particle system
  16184. */
  16185. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16186. /**
  16187. * Remove a specific emit rate gradient
  16188. * @param gradient defines the gradient to remove
  16189. * @returns the current particle system
  16190. */
  16191. removeEmitRateGradient(gradient: number): IParticleSystem;
  16192. /**
  16193. * Gets the current list of emit rate gradients.
  16194. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16195. * @returns the list of emit rate gradients
  16196. */
  16197. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16198. /**
  16199. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16200. * @param gradient defines the gradient to use (between 0 and 1)
  16201. * @param factor defines the start size to affect to the specified gradient
  16202. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16203. * @returns the current particle system
  16204. */
  16205. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16206. /**
  16207. * Remove a specific start size gradient
  16208. * @param gradient defines the gradient to remove
  16209. * @returns the current particle system
  16210. */
  16211. removeStartSizeGradient(gradient: number): IParticleSystem;
  16212. /**
  16213. * Gets the current list of start size gradients.
  16214. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16215. * @returns the list of start size gradients
  16216. */
  16217. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16218. /**
  16219. * Adds a new life time gradient
  16220. * @param gradient defines the gradient to use (between 0 and 1)
  16221. * @param factor defines the life time factor to affect to the specified gradient
  16222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16223. * @returns the current particle system
  16224. */
  16225. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16226. /**
  16227. * Remove a specific life time gradient
  16228. * @param gradient defines the gradient to remove
  16229. * @returns the current particle system
  16230. */
  16231. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16232. /**
  16233. * Gets the current list of life time gradients.
  16234. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16235. * @returns the list of life time gradients
  16236. */
  16237. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16238. /**
  16239. * Gets the current list of color gradients.
  16240. * You must use addColorGradient and removeColorGradient to udpate this list
  16241. * @returns the list of color gradients
  16242. */
  16243. getColorGradients(): Nullable<Array<ColorGradient>>;
  16244. /**
  16245. * Adds a new ramp gradient used to remap particle colors
  16246. * @param gradient defines the gradient to use (between 0 and 1)
  16247. * @param color defines the color to affect to the specified gradient
  16248. * @returns the current particle system
  16249. */
  16250. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16251. /**
  16252. * Gets the current list of ramp gradients.
  16253. * You must use addRampGradient and removeRampGradient to udpate this list
  16254. * @returns the list of ramp gradients
  16255. */
  16256. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16257. /** Gets or sets a boolean indicating that ramp gradients must be used
  16258. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16259. */
  16260. useRampGradients: boolean;
  16261. /**
  16262. * Adds a new color remap gradient
  16263. * @param gradient defines the gradient to use (between 0 and 1)
  16264. * @param min defines the color remap minimal range
  16265. * @param max defines the color remap maximal range
  16266. * @returns the current particle system
  16267. */
  16268. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16269. /**
  16270. * Gets the current list of color remap gradients.
  16271. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16272. * @returns the list of color remap gradients
  16273. */
  16274. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16275. /**
  16276. * Adds a new alpha remap gradient
  16277. * @param gradient defines the gradient to use (between 0 and 1)
  16278. * @param min defines the alpha remap minimal range
  16279. * @param max defines the alpha remap maximal range
  16280. * @returns the current particle system
  16281. */
  16282. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16283. /**
  16284. * Gets the current list of alpha remap gradients.
  16285. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16286. * @returns the list of alpha remap gradients
  16287. */
  16288. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16289. /**
  16290. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16291. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16292. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16293. * @returns the emitter
  16294. */
  16295. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16296. /**
  16297. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16298. * @param radius The radius of the hemisphere to emit from
  16299. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16300. * @returns the emitter
  16301. */
  16302. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16303. /**
  16304. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16305. * @param radius The radius of the sphere to emit from
  16306. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16307. * @returns the emitter
  16308. */
  16309. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16310. /**
  16311. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16312. * @param radius The radius of the sphere to emit from
  16313. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16314. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16315. * @returns the emitter
  16316. */
  16317. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16318. /**
  16319. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16320. * @param radius The radius of the emission cylinder
  16321. * @param height The height of the emission cylinder
  16322. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16323. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16324. * @returns the emitter
  16325. */
  16326. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16327. /**
  16328. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16329. * @param radius The radius of the cylinder to emit from
  16330. * @param height The height of the emission cylinder
  16331. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16332. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16333. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16334. * @returns the emitter
  16335. */
  16336. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16337. /**
  16338. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16339. * @param radius The radius of the cone to emit from
  16340. * @param angle The base angle of the cone
  16341. * @returns the emitter
  16342. */
  16343. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16344. /**
  16345. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16346. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16347. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16348. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16349. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16350. * @returns the emitter
  16351. */
  16352. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16353. /**
  16354. * Get hosting scene
  16355. * @returns the scene
  16356. */
  16357. getScene(): Scene;
  16358. }
  16359. }
  16360. declare module BABYLON {
  16361. /**
  16362. * Creates an instance based on a source mesh.
  16363. */
  16364. export class InstancedMesh extends AbstractMesh {
  16365. private _sourceMesh;
  16366. private _currentLOD;
  16367. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  16368. constructor(name: string, source: Mesh);
  16369. /**
  16370. * Returns the string "InstancedMesh".
  16371. */
  16372. getClassName(): string;
  16373. /** Gets the list of lights affecting that mesh */
  16374. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  16375. /**
  16376. * If the source mesh receives shadows
  16377. */
  16378. readonly receiveShadows: boolean;
  16379. /**
  16380. * The material of the source mesh
  16381. */
  16382. readonly material: Nullable<Material>;
  16383. /**
  16384. * Visibility of the source mesh
  16385. */
  16386. readonly visibility: number;
  16387. /**
  16388. * Skeleton of the source mesh
  16389. */
  16390. readonly skeleton: Nullable<Skeleton>;
  16391. /**
  16392. * Rendering ground id of the source mesh
  16393. */
  16394. renderingGroupId: number;
  16395. /**
  16396. * Returns the total number of vertices (integer).
  16397. */
  16398. getTotalVertices(): number;
  16399. /**
  16400. * Returns a positive integer : the total number of indices in this mesh geometry.
  16401. * @returns the numner of indices or zero if the mesh has no geometry.
  16402. */
  16403. getTotalIndices(): number;
  16404. /**
  16405. * The source mesh of the instance
  16406. */
  16407. readonly sourceMesh: Mesh;
  16408. /**
  16409. * Is this node ready to be used/rendered
  16410. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16411. * @return {boolean} is it ready
  16412. */
  16413. isReady(completeCheck?: boolean): boolean;
  16414. /**
  16415. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16416. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16417. * @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.
  16418. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16419. */
  16420. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16421. /**
  16422. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16423. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16424. * The `data` are either a numeric array either a Float32Array.
  16425. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16426. * 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).
  16427. * Note that a new underlying VertexBuffer object is created each call.
  16428. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16429. *
  16430. * Possible `kind` values :
  16431. * - VertexBuffer.PositionKind
  16432. * - VertexBuffer.UVKind
  16433. * - VertexBuffer.UV2Kind
  16434. * - VertexBuffer.UV3Kind
  16435. * - VertexBuffer.UV4Kind
  16436. * - VertexBuffer.UV5Kind
  16437. * - VertexBuffer.UV6Kind
  16438. * - VertexBuffer.ColorKind
  16439. * - VertexBuffer.MatricesIndicesKind
  16440. * - VertexBuffer.MatricesIndicesExtraKind
  16441. * - VertexBuffer.MatricesWeightsKind
  16442. * - VertexBuffer.MatricesWeightsExtraKind
  16443. *
  16444. * Returns the Mesh.
  16445. */
  16446. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16447. /**
  16448. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16449. * If the mesh has no geometry, it is simply returned as it is.
  16450. * The `data` are either a numeric array either a Float32Array.
  16451. * No new underlying VertexBuffer object is created.
  16452. * 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.
  16453. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16454. *
  16455. * Possible `kind` values :
  16456. * - VertexBuffer.PositionKind
  16457. * - VertexBuffer.UVKind
  16458. * - VertexBuffer.UV2Kind
  16459. * - VertexBuffer.UV3Kind
  16460. * - VertexBuffer.UV4Kind
  16461. * - VertexBuffer.UV5Kind
  16462. * - VertexBuffer.UV6Kind
  16463. * - VertexBuffer.ColorKind
  16464. * - VertexBuffer.MatricesIndicesKind
  16465. * - VertexBuffer.MatricesIndicesExtraKind
  16466. * - VertexBuffer.MatricesWeightsKind
  16467. * - VertexBuffer.MatricesWeightsExtraKind
  16468. *
  16469. * Returns the Mesh.
  16470. */
  16471. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16472. /**
  16473. * Sets the mesh indices.
  16474. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16475. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16476. * This method creates a new index buffer each call.
  16477. * Returns the Mesh.
  16478. */
  16479. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16480. /**
  16481. * Boolean : True if the mesh owns the requested kind of data.
  16482. */
  16483. isVerticesDataPresent(kind: string): boolean;
  16484. /**
  16485. * Returns an array of indices (IndicesArray).
  16486. */
  16487. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  16488. /**
  16489. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16490. * This means the mesh underlying bounding box and sphere are recomputed.
  16491. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16492. * @returns the current mesh
  16493. */
  16494. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16495. /** @hidden */ private _preActivate(): InstancedMesh;
  16496. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  16497. /** @hidden */ private _postActivate(): void;
  16498. getWorldMatrix(): Matrix;
  16499. readonly isAnInstance: boolean;
  16500. /**
  16501. * Returns the current associated LOD AbstractMesh.
  16502. */
  16503. getLOD(camera: Camera): AbstractMesh;
  16504. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  16505. /** @hidden */ private _generatePointsArray(): boolean;
  16506. /**
  16507. * Creates a new InstancedMesh from the current mesh.
  16508. * - name (string) : the cloned mesh name
  16509. * - newParent (optional Node) : the optional Node to parent the clone to.
  16510. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16511. *
  16512. * Returns the clone.
  16513. */
  16514. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  16515. /**
  16516. * Disposes the InstancedMesh.
  16517. * Returns nothing.
  16518. */
  16519. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16520. }
  16521. }
  16522. declare module BABYLON {
  16523. /**
  16524. * Defines the options associated with the creation of a shader material.
  16525. */
  16526. export interface IShaderMaterialOptions {
  16527. /**
  16528. * Does the material work in alpha blend mode
  16529. */
  16530. needAlphaBlending: boolean;
  16531. /**
  16532. * Does the material work in alpha test mode
  16533. */
  16534. needAlphaTesting: boolean;
  16535. /**
  16536. * The list of attribute names used in the shader
  16537. */
  16538. attributes: string[];
  16539. /**
  16540. * The list of unifrom names used in the shader
  16541. */
  16542. uniforms: string[];
  16543. /**
  16544. * The list of UBO names used in the shader
  16545. */
  16546. uniformBuffers: string[];
  16547. /**
  16548. * The list of sampler names used in the shader
  16549. */
  16550. samplers: string[];
  16551. /**
  16552. * The list of defines used in the shader
  16553. */
  16554. defines: string[];
  16555. }
  16556. /**
  16557. * 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.
  16558. *
  16559. * This returned material effects how the mesh will look based on the code in the shaders.
  16560. *
  16561. * @see http://doc.babylonjs.com/how_to/shader_material
  16562. */
  16563. export class ShaderMaterial extends Material {
  16564. private _shaderPath;
  16565. private _options;
  16566. private _textures;
  16567. private _textureArrays;
  16568. private _floats;
  16569. private _ints;
  16570. private _floatsArrays;
  16571. private _colors3;
  16572. private _colors3Arrays;
  16573. private _colors4;
  16574. private _vectors2;
  16575. private _vectors3;
  16576. private _vectors4;
  16577. private _matrices;
  16578. private _matrices3x3;
  16579. private _matrices2x2;
  16580. private _vectors2Arrays;
  16581. private _vectors3Arrays;
  16582. private _cachedWorldViewMatrix;
  16583. private _cachedWorldViewProjectionMatrix;
  16584. private _renderId;
  16585. /**
  16586. * Instantiate a new shader material.
  16587. * 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.
  16588. * This returned material effects how the mesh will look based on the code in the shaders.
  16589. * @see http://doc.babylonjs.com/how_to/shader_material
  16590. * @param name Define the name of the material in the scene
  16591. * @param scene Define the scene the material belongs to
  16592. * @param shaderPath Defines the route to the shader code in one of three ways:
  16593. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16594. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  16595. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16596. * @param options Define the options used to create the shader
  16597. */
  16598. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16599. /**
  16600. * Gets the options used to compile the shader.
  16601. * They can be modified to trigger a new compilation
  16602. */
  16603. readonly options: IShaderMaterialOptions;
  16604. /**
  16605. * Gets the current class name of the material e.g. "ShaderMaterial"
  16606. * Mainly use in serialization.
  16607. * @returns the class name
  16608. */
  16609. getClassName(): string;
  16610. /**
  16611. * Specifies if the material will require alpha blending
  16612. * @returns a boolean specifying if alpha blending is needed
  16613. */
  16614. needAlphaBlending(): boolean;
  16615. /**
  16616. * Specifies if this material should be rendered in alpha test mode
  16617. * @returns a boolean specifying if an alpha test is needed.
  16618. */
  16619. needAlphaTesting(): boolean;
  16620. private _checkUniform;
  16621. /**
  16622. * Set a texture in the shader.
  16623. * @param name Define the name of the uniform samplers as defined in the shader
  16624. * @param texture Define the texture to bind to this sampler
  16625. * @return the material itself allowing "fluent" like uniform updates
  16626. */
  16627. setTexture(name: string, texture: Texture): ShaderMaterial;
  16628. /**
  16629. * Set a texture array in the shader.
  16630. * @param name Define the name of the uniform sampler array as defined in the shader
  16631. * @param textures Define the list of textures to bind to this sampler
  16632. * @return the material itself allowing "fluent" like uniform updates
  16633. */
  16634. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  16635. /**
  16636. * Set a float in the shader.
  16637. * @param name Define the name of the uniform as defined in the shader
  16638. * @param value Define the value to give to the uniform
  16639. * @return the material itself allowing "fluent" like uniform updates
  16640. */
  16641. setFloat(name: string, value: number): ShaderMaterial;
  16642. /**
  16643. * Set a int in the shader.
  16644. * @param name Define the name of the uniform as defined in the shader
  16645. * @param value Define the value to give to the uniform
  16646. * @return the material itself allowing "fluent" like uniform updates
  16647. */
  16648. setInt(name: string, value: number): ShaderMaterial;
  16649. /**
  16650. * Set an array of floats in the shader.
  16651. * @param name Define the name of the uniform as defined in the shader
  16652. * @param value Define the value to give to the uniform
  16653. * @return the material itself allowing "fluent" like uniform updates
  16654. */
  16655. setFloats(name: string, value: number[]): ShaderMaterial;
  16656. /**
  16657. * Set a vec3 in the shader from a Color3.
  16658. * @param name Define the name of the uniform as defined in the shader
  16659. * @param value Define the value to give to the uniform
  16660. * @return the material itself allowing "fluent" like uniform updates
  16661. */
  16662. setColor3(name: string, value: Color3): ShaderMaterial;
  16663. /**
  16664. * Set a vec3 array in the shader from a Color3 array.
  16665. * @param name Define the name of the uniform as defined in the shader
  16666. * @param value Define the value to give to the uniform
  16667. * @return the material itself allowing "fluent" like uniform updates
  16668. */
  16669. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16670. /**
  16671. * Set a vec4 in the shader from a Color4.
  16672. * @param name Define the name of the uniform as defined in the shader
  16673. * @param value Define the value to give to the uniform
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setColor4(name: string, value: Color4): ShaderMaterial;
  16677. /**
  16678. * Set a vec2 in the shader from a Vector2.
  16679. * @param name Define the name of the uniform as defined in the shader
  16680. * @param value Define the value to give to the uniform
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setVector2(name: string, value: Vector2): ShaderMaterial;
  16684. /**
  16685. * Set a vec3 in the shader from a Vector3.
  16686. * @param name Define the name of the uniform as defined in the shader
  16687. * @param value Define the value to give to the uniform
  16688. * @return the material itself allowing "fluent" like uniform updates
  16689. */
  16690. setVector3(name: string, value: Vector3): ShaderMaterial;
  16691. /**
  16692. * Set a vec4 in the shader from a Vector4.
  16693. * @param name Define the name of the uniform as defined in the shader
  16694. * @param value Define the value to give to the uniform
  16695. * @return the material itself allowing "fluent" like uniform updates
  16696. */
  16697. setVector4(name: string, value: Vector4): ShaderMaterial;
  16698. /**
  16699. * Set a mat4 in the shader from a Matrix.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the material itself allowing "fluent" like uniform updates
  16703. */
  16704. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16705. /**
  16706. * Set a mat3 in the shader from a Float32Array.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the material itself allowing "fluent" like uniform updates
  16710. */
  16711. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16712. /**
  16713. * Set a mat2 in the shader from a Float32Array.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the material itself allowing "fluent" like uniform updates
  16717. */
  16718. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16719. /**
  16720. * Set a vec2 array in the shader from a number array.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the material itself allowing "fluent" like uniform updates
  16724. */
  16725. setArray2(name: string, value: number[]): ShaderMaterial;
  16726. /**
  16727. * Set a vec3 array in the shader from a number array.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the material itself allowing "fluent" like uniform updates
  16731. */
  16732. setArray3(name: string, value: number[]): ShaderMaterial;
  16733. private _checkCache;
  16734. /**
  16735. * Specifies that the submesh is ready to be used
  16736. * @param mesh defines the mesh to check
  16737. * @param subMesh defines which submesh to check
  16738. * @param useInstances specifies that instances should be used
  16739. * @returns a boolean indicating that the submesh is ready or not
  16740. */
  16741. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  16742. /**
  16743. * Checks if the material is ready to render the requested mesh
  16744. * @param mesh Define the mesh to render
  16745. * @param useInstances Define whether or not the material is used with instances
  16746. * @returns true if ready, otherwise false
  16747. */
  16748. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16749. /**
  16750. * Binds the world matrix to the material
  16751. * @param world defines the world transformation matrix
  16752. */
  16753. bindOnlyWorldMatrix(world: Matrix): void;
  16754. /**
  16755. * Binds the material to the mesh
  16756. * @param world defines the world transformation matrix
  16757. * @param mesh defines the mesh to bind the material to
  16758. */
  16759. bind(world: Matrix, mesh?: Mesh): void;
  16760. /**
  16761. * Gets the active textures from the material
  16762. * @returns an array of textures
  16763. */
  16764. getActiveTextures(): BaseTexture[];
  16765. /**
  16766. * Specifies if the material uses a texture
  16767. * @param texture defines the texture to check against the material
  16768. * @returns a boolean specifying if the material uses the texture
  16769. */
  16770. hasTexture(texture: BaseTexture): boolean;
  16771. /**
  16772. * Makes a duplicate of the material, and gives it a new name
  16773. * @param name defines the new name for the duplicated material
  16774. * @returns the cloned material
  16775. */
  16776. clone(name: string): ShaderMaterial;
  16777. /**
  16778. * Disposes the material
  16779. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16780. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16781. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16782. */
  16783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16784. /**
  16785. * Serializes this material in a JSON representation
  16786. * @returns the serialized material object
  16787. */
  16788. serialize(): any;
  16789. /**
  16790. * Creates a shader material from parsed shader material data
  16791. * @param source defines the JSON represnetation of the material
  16792. * @param scene defines the hosting scene
  16793. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16794. * @returns a new material
  16795. */
  16796. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16797. }
  16798. }
  16799. declare module BABYLON {
  16800. /** @hidden */
  16801. export var colorPixelShader: {
  16802. name: string;
  16803. shader: string;
  16804. };
  16805. }
  16806. declare module BABYLON {
  16807. /** @hidden */
  16808. export var colorVertexShader: {
  16809. name: string;
  16810. shader: string;
  16811. };
  16812. }
  16813. declare module BABYLON {
  16814. /**
  16815. * Line mesh
  16816. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16817. */
  16818. export class LinesMesh extends Mesh {
  16819. /**
  16820. * If vertex color should be applied to the mesh
  16821. */
  16822. readonly useVertexColor?: boolean | undefined;
  16823. /**
  16824. * If vertex alpha should be applied to the mesh
  16825. */
  16826. readonly useVertexAlpha?: boolean | undefined;
  16827. /**
  16828. * Color of the line (Default: White)
  16829. */
  16830. color: Color3;
  16831. /**
  16832. * Alpha of the line (Default: 1)
  16833. */
  16834. alpha: number;
  16835. /**
  16836. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16837. * This margin is expressed in world space coordinates, so its value may vary.
  16838. * Default value is 0.1
  16839. */
  16840. intersectionThreshold: number;
  16841. private _colorShader;
  16842. private color4;
  16843. /**
  16844. * Creates a new LinesMesh
  16845. * @param name defines the name
  16846. * @param scene defines the hosting scene
  16847. * @param parent defines the parent mesh if any
  16848. * @param source defines the optional source LinesMesh used to clone data from
  16849. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16850. * When false, achieved by calling a clone(), also passing False.
  16851. * This will make creation of children, recursive.
  16852. * @param useVertexColor defines if this LinesMesh supports vertex color
  16853. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16854. */
  16855. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  16856. /**
  16857. * If vertex color should be applied to the mesh
  16858. */
  16859. useVertexColor?: boolean | undefined,
  16860. /**
  16861. * If vertex alpha should be applied to the mesh
  16862. */
  16863. useVertexAlpha?: boolean | undefined);
  16864. private _addClipPlaneDefine;
  16865. private _removeClipPlaneDefine;
  16866. isReady(): boolean;
  16867. /**
  16868. * Returns the string "LineMesh"
  16869. */
  16870. getClassName(): string;
  16871. /**
  16872. * @hidden
  16873. */
  16874. /**
  16875. * @hidden
  16876. */
  16877. material: Material;
  16878. /**
  16879. * @hidden
  16880. */
  16881. readonly checkCollisions: boolean;
  16882. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  16883. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  16884. /**
  16885. * Disposes of the line mesh
  16886. * @param doNotRecurse If children should be disposed
  16887. */
  16888. dispose(doNotRecurse?: boolean): void;
  16889. /**
  16890. * Returns a new LineMesh object cloned from the current one.
  16891. */
  16892. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  16893. /**
  16894. * Creates a new InstancedLinesMesh object from the mesh model.
  16895. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16896. * @param name defines the name of the new instance
  16897. * @returns a new InstancedLinesMesh
  16898. */
  16899. createInstance(name: string): InstancedLinesMesh;
  16900. }
  16901. /**
  16902. * Creates an instance based on a source LinesMesh
  16903. */
  16904. export class InstancedLinesMesh extends InstancedMesh {
  16905. /**
  16906. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16907. * This margin is expressed in world space coordinates, so its value may vary.
  16908. * Initilized with the intersectionThreshold value of the source LinesMesh
  16909. */
  16910. intersectionThreshold: number;
  16911. constructor(name: string, source: LinesMesh);
  16912. /**
  16913. * Returns the string "InstancedLinesMesh".
  16914. */
  16915. getClassName(): string;
  16916. }
  16917. }
  16918. declare module BABYLON {
  16919. /** @hidden */
  16920. export var linePixelShader: {
  16921. name: string;
  16922. shader: string;
  16923. };
  16924. }
  16925. declare module BABYLON {
  16926. /** @hidden */
  16927. export var lineVertexShader: {
  16928. name: string;
  16929. shader: string;
  16930. };
  16931. }
  16932. declare module BABYLON {
  16933. interface AbstractMesh {
  16934. /**
  16935. * Gets the edgesRenderer associated with the mesh
  16936. */
  16937. edgesRenderer: Nullable<EdgesRenderer>;
  16938. }
  16939. interface LinesMesh {
  16940. /**
  16941. * Enables the edge rendering mode on the mesh.
  16942. * This mode makes the mesh edges visible
  16943. * @param epsilon defines the maximal distance between two angles to detect a face
  16944. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16945. * @returns the currentAbstractMesh
  16946. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16947. */
  16948. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16949. }
  16950. interface InstancedLinesMesh {
  16951. /**
  16952. * Enables the edge rendering mode on the mesh.
  16953. * This mode makes the mesh edges visible
  16954. * @param epsilon defines the maximal distance between two angles to detect a face
  16955. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16956. * @returns the current InstancedLinesMesh
  16957. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16958. */
  16959. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16960. }
  16961. /**
  16962. * Defines the minimum contract an Edges renderer should follow.
  16963. */
  16964. export interface IEdgesRenderer extends IDisposable {
  16965. /**
  16966. * Gets or sets a boolean indicating if the edgesRenderer is active
  16967. */
  16968. isEnabled: boolean;
  16969. /**
  16970. * Renders the edges of the attached mesh,
  16971. */
  16972. render(): void;
  16973. /**
  16974. * Checks wether or not the edges renderer is ready to render.
  16975. * @return true if ready, otherwise false.
  16976. */
  16977. isReady(): boolean;
  16978. }
  16979. /**
  16980. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16981. */
  16982. export class EdgesRenderer implements IEdgesRenderer {
  16983. /**
  16984. * Define the size of the edges with an orthographic camera
  16985. */
  16986. edgesWidthScalerForOrthographic: number;
  16987. /**
  16988. * Define the size of the edges with a perspective camera
  16989. */
  16990. edgesWidthScalerForPerspective: number;
  16991. protected _source: AbstractMesh;
  16992. protected _linesPositions: number[];
  16993. protected _linesNormals: number[];
  16994. protected _linesIndices: number[];
  16995. protected _epsilon: number;
  16996. protected _indicesCount: number;
  16997. protected _lineShader: ShaderMaterial;
  16998. protected _ib: DataBuffer;
  16999. protected _buffers: {
  17000. [key: string]: Nullable<VertexBuffer>;
  17001. };
  17002. protected _checkVerticesInsteadOfIndices: boolean;
  17003. private _meshRebuildObserver;
  17004. private _meshDisposeObserver;
  17005. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17006. isEnabled: boolean;
  17007. /**
  17008. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17009. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17010. * @param source Mesh used to create edges
  17011. * @param epsilon sum of angles in adjacency to check for edge
  17012. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17013. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17014. */
  17015. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17016. protected _prepareRessources(): void;
  17017. /** @hidden */ private _rebuild(): void;
  17018. /**
  17019. * Releases the required resources for the edges renderer
  17020. */
  17021. dispose(): void;
  17022. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17023. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17024. /**
  17025. * Checks if the pair of p0 and p1 is en edge
  17026. * @param faceIndex
  17027. * @param edge
  17028. * @param faceNormals
  17029. * @param p0
  17030. * @param p1
  17031. * @private
  17032. */
  17033. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17034. /**
  17035. * push line into the position, normal and index buffer
  17036. * @protected
  17037. */
  17038. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17039. /**
  17040. * Generates lines edges from adjacencjes
  17041. * @private
  17042. */ private _generateEdgesLines(): void;
  17043. /**
  17044. * Checks wether or not the edges renderer is ready to render.
  17045. * @return true if ready, otherwise false.
  17046. */
  17047. isReady(): boolean;
  17048. /**
  17049. * Renders the edges of the attached mesh,
  17050. */
  17051. render(): void;
  17052. }
  17053. /**
  17054. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17055. */
  17056. export class LineEdgesRenderer extends EdgesRenderer {
  17057. /**
  17058. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17059. * @param source LineMesh used to generate edges
  17060. * @param epsilon not important (specified angle for edge detection)
  17061. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17062. */
  17063. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17064. /**
  17065. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17066. */ private _generateEdgesLines(): void;
  17067. }
  17068. }
  17069. declare module BABYLON {
  17070. /**
  17071. * This represents the object necessary to create a rendering group.
  17072. * This is exclusively used and created by the rendering manager.
  17073. * To modify the behavior, you use the available helpers in your scene or meshes.
  17074. * @hidden
  17075. */
  17076. export class RenderingGroup {
  17077. index: number;
  17078. private static _zeroVector;
  17079. private _scene;
  17080. private _opaqueSubMeshes;
  17081. private _transparentSubMeshes;
  17082. private _alphaTestSubMeshes;
  17083. private _depthOnlySubMeshes;
  17084. private _particleSystems;
  17085. private _spriteManagers;
  17086. private _opaqueSortCompareFn;
  17087. private _alphaTestSortCompareFn;
  17088. private _transparentSortCompareFn;
  17089. private _renderOpaque;
  17090. private _renderAlphaTest;
  17091. private _renderTransparent;
  17092. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  17093. onBeforeTransparentRendering: () => void;
  17094. /**
  17095. * Set the opaque sort comparison function.
  17096. * If null the sub meshes will be render in the order they were created
  17097. */
  17098. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17099. /**
  17100. * Set the alpha test sort comparison function.
  17101. * If null the sub meshes will be render in the order they were created
  17102. */
  17103. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17104. /**
  17105. * Set the transparent sort comparison function.
  17106. * If null the sub meshes will be render in the order they were created
  17107. */
  17108. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17109. /**
  17110. * Creates a new rendering group.
  17111. * @param index The rendering group index
  17112. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17113. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17114. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17115. */
  17116. 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>);
  17117. /**
  17118. * Render all the sub meshes contained in the group.
  17119. * @param customRenderFunction Used to override the default render behaviour of the group.
  17120. * @returns true if rendered some submeshes.
  17121. */
  17122. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17123. /**
  17124. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17125. * @param subMeshes The submeshes to render
  17126. */
  17127. private renderOpaqueSorted;
  17128. /**
  17129. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17130. * @param subMeshes The submeshes to render
  17131. */
  17132. private renderAlphaTestSorted;
  17133. /**
  17134. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17135. * @param subMeshes The submeshes to render
  17136. */
  17137. private renderTransparentSorted;
  17138. /**
  17139. * Renders the submeshes in a specified order.
  17140. * @param subMeshes The submeshes to sort before render
  17141. * @param sortCompareFn The comparison function use to sort
  17142. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17143. * @param transparent Specifies to activate blending if true
  17144. */
  17145. private static renderSorted;
  17146. /**
  17147. * Renders the submeshes in the order they were dispatched (no sort applied).
  17148. * @param subMeshes The submeshes to render
  17149. */
  17150. private static renderUnsorted;
  17151. /**
  17152. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17153. * are rendered back to front if in the same alpha index.
  17154. *
  17155. * @param a The first submesh
  17156. * @param b The second submesh
  17157. * @returns The result of the comparison
  17158. */
  17159. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17160. /**
  17161. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17162. * are rendered back to front.
  17163. *
  17164. * @param a The first submesh
  17165. * @param b The second submesh
  17166. * @returns The result of the comparison
  17167. */
  17168. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17169. /**
  17170. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17171. * are rendered front to back (prevent overdraw).
  17172. *
  17173. * @param a The first submesh
  17174. * @param b The second submesh
  17175. * @returns The result of the comparison
  17176. */
  17177. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17178. /**
  17179. * Resets the different lists of submeshes to prepare a new frame.
  17180. */
  17181. prepare(): void;
  17182. dispose(): void;
  17183. /**
  17184. * Inserts the submesh in its correct queue depending on its material.
  17185. * @param subMesh The submesh to dispatch
  17186. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17187. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17188. */
  17189. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17190. dispatchSprites(spriteManager: ISpriteManager): void;
  17191. dispatchParticles(particleSystem: IParticleSystem): void;
  17192. private _renderParticles;
  17193. private _renderSprites;
  17194. }
  17195. }
  17196. declare module BABYLON {
  17197. /**
  17198. * Interface describing the different options available in the rendering manager
  17199. * regarding Auto Clear between groups.
  17200. */
  17201. export interface IRenderingManagerAutoClearSetup {
  17202. /**
  17203. * Defines whether or not autoclear is enable.
  17204. */
  17205. autoClear: boolean;
  17206. /**
  17207. * Defines whether or not to autoclear the depth buffer.
  17208. */
  17209. depth: boolean;
  17210. /**
  17211. * Defines whether or not to autoclear the stencil buffer.
  17212. */
  17213. stencil: boolean;
  17214. }
  17215. /**
  17216. * This class is used by the onRenderingGroupObservable
  17217. */
  17218. export class RenderingGroupInfo {
  17219. /**
  17220. * The Scene that being rendered
  17221. */
  17222. scene: Scene;
  17223. /**
  17224. * The camera currently used for the rendering pass
  17225. */
  17226. camera: Nullable<Camera>;
  17227. /**
  17228. * The ID of the renderingGroup being processed
  17229. */
  17230. renderingGroupId: number;
  17231. }
  17232. /**
  17233. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17234. * It is enable to manage the different groups as well as the different necessary sort functions.
  17235. * This should not be used directly aside of the few static configurations
  17236. */
  17237. export class RenderingManager {
  17238. /**
  17239. * The max id used for rendering groups (not included)
  17240. */
  17241. static MAX_RENDERINGGROUPS: number;
  17242. /**
  17243. * The min id used for rendering groups (included)
  17244. */
  17245. static MIN_RENDERINGGROUPS: number;
  17246. /**
  17247. * Used to globally prevent autoclearing scenes.
  17248. */
  17249. static AUTOCLEAR: boolean;
  17250. /**
  17251. * @hidden
  17252. */ private _useSceneAutoClearSetup: boolean;
  17253. private _scene;
  17254. private _renderingGroups;
  17255. private _depthStencilBufferAlreadyCleaned;
  17256. private _autoClearDepthStencil;
  17257. private _customOpaqueSortCompareFn;
  17258. private _customAlphaTestSortCompareFn;
  17259. private _customTransparentSortCompareFn;
  17260. private _renderingGroupInfo;
  17261. /**
  17262. * Instantiates a new rendering group for a particular scene
  17263. * @param scene Defines the scene the groups belongs to
  17264. */
  17265. constructor(scene: Scene);
  17266. private _clearDepthStencilBuffer;
  17267. /**
  17268. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17269. * @hidden
  17270. */
  17271. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17272. /**
  17273. * Resets the different information of the group to prepare a new frame
  17274. * @hidden
  17275. */
  17276. reset(): void;
  17277. /**
  17278. * Dispose and release the group and its associated resources.
  17279. * @hidden
  17280. */
  17281. dispose(): void;
  17282. /**
  17283. * Clear the info related to rendering groups preventing retention points during dispose.
  17284. */
  17285. freeRenderingGroups(): void;
  17286. private _prepareRenderingGroup;
  17287. /**
  17288. * Add a sprite manager to the rendering manager in order to render it this frame.
  17289. * @param spriteManager Define the sprite manager to render
  17290. */
  17291. dispatchSprites(spriteManager: ISpriteManager): void;
  17292. /**
  17293. * Add a particle system to the rendering manager in order to render it this frame.
  17294. * @param particleSystem Define the particle system to render
  17295. */
  17296. dispatchParticles(particleSystem: IParticleSystem): void;
  17297. /**
  17298. * Add a submesh to the manager in order to render it this frame
  17299. * @param subMesh The submesh to dispatch
  17300. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17301. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17302. */
  17303. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17304. /**
  17305. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17306. * This allowed control for front to back rendering or reversly depending of the special needs.
  17307. *
  17308. * @param renderingGroupId The rendering group id corresponding to its index
  17309. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17310. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17311. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17312. */
  17313. 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;
  17314. /**
  17315. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17316. *
  17317. * @param renderingGroupId The rendering group id corresponding to its index
  17318. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17319. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17320. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17321. */
  17322. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17323. /**
  17324. * Gets the current auto clear configuration for one rendering group of the rendering
  17325. * manager.
  17326. * @param index the rendering group index to get the information for
  17327. * @returns The auto clear setup for the requested rendering group
  17328. */
  17329. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17330. }
  17331. }
  17332. declare module BABYLON {
  17333. /**
  17334. * This Helps creating a texture that will be created from a camera in your scene.
  17335. * It is basically a dynamic texture that could be used to create special effects for instance.
  17336. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17337. */
  17338. export class RenderTargetTexture extends Texture {
  17339. isCube: boolean;
  17340. /**
  17341. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17342. */
  17343. static readonly REFRESHRATE_RENDER_ONCE: number;
  17344. /**
  17345. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17346. */
  17347. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17348. /**
  17349. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17350. * the central point of your effect and can save a lot of performances.
  17351. */
  17352. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17353. /**
  17354. * Use this predicate to dynamically define the list of mesh you want to render.
  17355. * If set, the renderList property will be overwritten.
  17356. */
  17357. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17358. private _renderList;
  17359. /**
  17360. * Use this list to define the list of mesh you want to render.
  17361. */
  17362. renderList: Nullable<Array<AbstractMesh>>;
  17363. private _hookArray;
  17364. /**
  17365. * Define if particles should be rendered in your texture.
  17366. */
  17367. renderParticles: boolean;
  17368. /**
  17369. * Define if sprites should be rendered in your texture.
  17370. */
  17371. renderSprites: boolean;
  17372. /**
  17373. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17374. */
  17375. coordinatesMode: number;
  17376. /**
  17377. * Define the camera used to render the texture.
  17378. */
  17379. activeCamera: Nullable<Camera>;
  17380. /**
  17381. * Override the render function of the texture with your own one.
  17382. */
  17383. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17384. /**
  17385. * Define if camera post processes should be use while rendering the texture.
  17386. */
  17387. useCameraPostProcesses: boolean;
  17388. /**
  17389. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17390. */
  17391. ignoreCameraViewport: boolean;
  17392. private _postProcessManager;
  17393. private _postProcesses;
  17394. private _resizeObserver;
  17395. /**
  17396. * An event triggered when the texture is unbind.
  17397. */
  17398. onBeforeBindObservable: Observable<RenderTargetTexture>;
  17399. /**
  17400. * An event triggered when the texture is unbind.
  17401. */
  17402. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  17403. private _onAfterUnbindObserver;
  17404. /**
  17405. * Set a after unbind callback in the texture.
  17406. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  17407. */
  17408. onAfterUnbind: () => void;
  17409. /**
  17410. * An event triggered before rendering the texture
  17411. */
  17412. onBeforeRenderObservable: Observable<number>;
  17413. private _onBeforeRenderObserver;
  17414. /**
  17415. * Set a before render callback in the texture.
  17416. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  17417. */
  17418. onBeforeRender: (faceIndex: number) => void;
  17419. /**
  17420. * An event triggered after rendering the texture
  17421. */
  17422. onAfterRenderObservable: Observable<number>;
  17423. private _onAfterRenderObserver;
  17424. /**
  17425. * Set a after render callback in the texture.
  17426. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  17427. */
  17428. onAfterRender: (faceIndex: number) => void;
  17429. /**
  17430. * An event triggered after the texture clear
  17431. */
  17432. onClearObservable: Observable<Engine>;
  17433. private _onClearObserver;
  17434. /**
  17435. * Set a clear callback in the texture.
  17436. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  17437. */
  17438. onClear: (Engine: Engine) => void;
  17439. /**
  17440. * Define the clear color of the Render Target if it should be different from the scene.
  17441. */
  17442. clearColor: Color4;
  17443. protected _size: number | {
  17444. width: number;
  17445. height: number;
  17446. };
  17447. protected _initialSizeParameter: number | {
  17448. width: number;
  17449. height: number;
  17450. } | {
  17451. ratio: number;
  17452. };
  17453. protected _sizeRatio: Nullable<number>;
  17454. /** @hidden */ private _generateMipMaps: boolean;
  17455. protected _renderingManager: RenderingManager;
  17456. /** @hidden */ private _waitingRenderList: string[];
  17457. protected _doNotChangeAspectRatio: boolean;
  17458. protected _currentRefreshId: number;
  17459. protected _refreshRate: number;
  17460. protected _textureMatrix: Matrix;
  17461. protected _samples: number;
  17462. protected _renderTargetOptions: RenderTargetCreationOptions;
  17463. /**
  17464. * Gets render target creation options that were used.
  17465. */
  17466. readonly renderTargetOptions: RenderTargetCreationOptions;
  17467. protected _engine: Engine;
  17468. protected _onRatioRescale(): void;
  17469. /**
  17470. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  17471. * It must define where the camera used to render the texture is set
  17472. */
  17473. boundingBoxPosition: Vector3;
  17474. private _boundingBoxSize;
  17475. /**
  17476. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  17477. * When defined, the cubemap will switch to local mode
  17478. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  17479. * @example https://www.babylonjs-playground.com/#RNASML
  17480. */
  17481. boundingBoxSize: Vector3;
  17482. /**
  17483. * In case the RTT has been created with a depth texture, get the associated
  17484. * depth texture.
  17485. * Otherwise, return null.
  17486. */
  17487. depthStencilTexture: Nullable<InternalTexture>;
  17488. /**
  17489. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  17490. * or used a shadow, depth texture...
  17491. * @param name The friendly name of the texture
  17492. * @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)
  17493. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  17494. * @param generateMipMaps True if mip maps need to be generated after render.
  17495. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  17496. * @param type The type of the buffer in the RTT (int, half float, float...)
  17497. * @param isCube True if a cube texture needs to be created
  17498. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  17499. * @param generateDepthBuffer True to generate a depth buffer
  17500. * @param generateStencilBuffer True to generate a stencil buffer
  17501. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  17502. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  17503. * @param delayAllocation if the texture allocation should be delayed (default: false)
  17504. */
  17505. constructor(name: string, size: number | {
  17506. width: number;
  17507. height: number;
  17508. } | {
  17509. ratio: number;
  17510. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  17511. /**
  17512. * Creates a depth stencil texture.
  17513. * This is only available in WebGL 2 or with the depth texture extension available.
  17514. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  17515. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  17516. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  17517. */
  17518. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  17519. private _processSizeParameter;
  17520. /**
  17521. * Define the number of samples to use in case of MSAA.
  17522. * It defaults to one meaning no MSAA has been enabled.
  17523. */
  17524. samples: number;
  17525. /**
  17526. * Resets the refresh counter of the texture and start bak from scratch.
  17527. * Could be useful to regenerate the texture if it is setup to render only once.
  17528. */
  17529. resetRefreshCounter(): void;
  17530. /**
  17531. * Define the refresh rate of the texture or the rendering frequency.
  17532. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  17533. */
  17534. refreshRate: number;
  17535. /**
  17536. * Adds a post process to the render target rendering passes.
  17537. * @param postProcess define the post process to add
  17538. */
  17539. addPostProcess(postProcess: PostProcess): void;
  17540. /**
  17541. * Clear all the post processes attached to the render target
  17542. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  17543. */
  17544. clearPostProcesses(dispose?: boolean): void;
  17545. /**
  17546. * Remove one of the post process from the list of attached post processes to the texture
  17547. * @param postProcess define the post process to remove from the list
  17548. */
  17549. removePostProcess(postProcess: PostProcess): void;
  17550. /** @hidden */ private _shouldRender(): boolean;
  17551. /**
  17552. * Gets the actual render size of the texture.
  17553. * @returns the width of the render size
  17554. */
  17555. getRenderSize(): number;
  17556. /**
  17557. * Gets the actual render width of the texture.
  17558. * @returns the width of the render size
  17559. */
  17560. getRenderWidth(): number;
  17561. /**
  17562. * Gets the actual render height of the texture.
  17563. * @returns the height of the render size
  17564. */
  17565. getRenderHeight(): number;
  17566. /**
  17567. * Get if the texture can be rescaled or not.
  17568. */
  17569. readonly canRescale: boolean;
  17570. /**
  17571. * Resize the texture using a ratio.
  17572. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  17573. */
  17574. scale(ratio: number): void;
  17575. /**
  17576. * Get the texture reflection matrix used to rotate/transform the reflection.
  17577. * @returns the reflection matrix
  17578. */
  17579. getReflectionTextureMatrix(): Matrix;
  17580. /**
  17581. * Resize the texture to a new desired size.
  17582. * Be carrefull as it will recreate all the data in the new texture.
  17583. * @param size Define the new size. It can be:
  17584. * - a number for squared texture,
  17585. * - an object containing { width: number, height: number }
  17586. * - or an object containing a ratio { ratio: number }
  17587. */
  17588. resize(size: number | {
  17589. width: number;
  17590. height: number;
  17591. } | {
  17592. ratio: number;
  17593. }): void;
  17594. /**
  17595. * Renders all the objects from the render list into the texture.
  17596. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  17597. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  17598. */
  17599. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  17600. private _bestReflectionRenderTargetDimension;
  17601. /**
  17602. * @hidden
  17603. * @param faceIndex face index to bind to if this is a cubetexture
  17604. */ private _bindFrameBuffer(faceIndex?: number): void;
  17605. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  17606. private renderToTarget;
  17607. /**
  17608. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17609. * This allowed control for front to back rendering or reversly depending of the special needs.
  17610. *
  17611. * @param renderingGroupId The rendering group id corresponding to its index
  17612. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17613. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17614. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17615. */
  17616. 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;
  17617. /**
  17618. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17619. *
  17620. * @param renderingGroupId The rendering group id corresponding to its index
  17621. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17622. */
  17623. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  17624. /**
  17625. * Clones the texture.
  17626. * @returns the cloned texture
  17627. */
  17628. clone(): RenderTargetTexture;
  17629. /**
  17630. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17631. * @returns The JSON representation of the texture
  17632. */
  17633. serialize(): any;
  17634. /**
  17635. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  17636. */
  17637. disposeFramebufferObjects(): void;
  17638. /**
  17639. * Dispose the texture and release its associated resources.
  17640. */
  17641. dispose(): void;
  17642. /** @hidden */ private _rebuild(): void;
  17643. /**
  17644. * Clear the info related to rendering groups preventing retention point in material dispose.
  17645. */
  17646. freeRenderingGroups(): void;
  17647. /**
  17648. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  17649. * @returns the view count
  17650. */
  17651. getViewCount(): number;
  17652. }
  17653. }
  17654. declare module BABYLON {
  17655. /**
  17656. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17657. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17658. * You can then easily use it as a reflectionTexture on a flat surface.
  17659. * In case the surface is not a plane, please consider relying on reflection probes.
  17660. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17661. */
  17662. export class MirrorTexture extends RenderTargetTexture {
  17663. private scene;
  17664. /**
  17665. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  17666. * 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.
  17667. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17668. */
  17669. mirrorPlane: Plane;
  17670. /**
  17671. * Define the blur ratio used to blur the reflection if needed.
  17672. */
  17673. blurRatio: number;
  17674. /**
  17675. * Define the adaptive blur kernel used to blur the reflection if needed.
  17676. * This will autocompute the closest best match for the `blurKernel`
  17677. */
  17678. adaptiveBlurKernel: number;
  17679. /**
  17680. * Define the blur kernel used to blur the reflection if needed.
  17681. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17682. */
  17683. blurKernel: number;
  17684. /**
  17685. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  17686. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17687. */
  17688. blurKernelX: number;
  17689. /**
  17690. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  17691. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  17692. */
  17693. blurKernelY: number;
  17694. private _autoComputeBlurKernel;
  17695. protected _onRatioRescale(): void;
  17696. private _updateGammaSpace;
  17697. private _imageProcessingConfigChangeObserver;
  17698. private _transformMatrix;
  17699. private _mirrorMatrix;
  17700. private _savedViewMatrix;
  17701. private _blurX;
  17702. private _blurY;
  17703. private _adaptiveBlurKernel;
  17704. private _blurKernelX;
  17705. private _blurKernelY;
  17706. private _blurRatio;
  17707. /**
  17708. * Instantiates a Mirror Texture.
  17709. * Mirror texture can be used to simulate the view from a mirror in a scene.
  17710. * It will dynamically be rendered every frame to adapt to the camera point of view.
  17711. * You can then easily use it as a reflectionTexture on a flat surface.
  17712. * In case the surface is not a plane, please consider relying on reflection probes.
  17713. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  17714. * @param name
  17715. * @param size
  17716. * @param scene
  17717. * @param generateMipMaps
  17718. * @param type
  17719. * @param samplingMode
  17720. * @param generateDepthBuffer
  17721. */
  17722. constructor(name: string, size: number | {
  17723. width: number;
  17724. height: number;
  17725. } | {
  17726. ratio: number;
  17727. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  17728. private _preparePostProcesses;
  17729. /**
  17730. * Clone the mirror texture.
  17731. * @returns the cloned texture
  17732. */
  17733. clone(): MirrorTexture;
  17734. /**
  17735. * Serialize the texture to a JSON representation you could use in Parse later on
  17736. * @returns the serialized JSON representation
  17737. */
  17738. serialize(): any;
  17739. /**
  17740. * Dispose the texture and release its associated resources.
  17741. */
  17742. dispose(): void;
  17743. }
  17744. }
  17745. declare module BABYLON {
  17746. /**
  17747. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17748. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17749. */
  17750. export class Texture extends BaseTexture {
  17751. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  17752. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  17753. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  17754. /** nearest is mag = nearest and min = nearest and mip = linear */
  17755. static readonly NEAREST_SAMPLINGMODE: number;
  17756. /** nearest is mag = nearest and min = nearest and mip = linear */
  17757. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  17758. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17759. static readonly BILINEAR_SAMPLINGMODE: number;
  17760. /** Bilinear is mag = linear and min = linear and mip = nearest */
  17761. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  17762. /** Trilinear is mag = linear and min = linear and mip = linear */
  17763. static readonly TRILINEAR_SAMPLINGMODE: number;
  17764. /** Trilinear is mag = linear and min = linear and mip = linear */
  17765. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  17766. /** mag = nearest and min = nearest and mip = nearest */
  17767. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  17768. /** mag = nearest and min = linear and mip = nearest */
  17769. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  17770. /** mag = nearest and min = linear and mip = linear */
  17771. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  17772. /** mag = nearest and min = linear and mip = none */
  17773. static readonly NEAREST_LINEAR: number;
  17774. /** mag = nearest and min = nearest and mip = none */
  17775. static readonly NEAREST_NEAREST: number;
  17776. /** mag = linear and min = nearest and mip = nearest */
  17777. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  17778. /** mag = linear and min = nearest and mip = linear */
  17779. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  17780. /** mag = linear and min = linear and mip = none */
  17781. static readonly LINEAR_LINEAR: number;
  17782. /** mag = linear and min = nearest and mip = none */
  17783. static readonly LINEAR_NEAREST: number;
  17784. /** Explicit coordinates mode */
  17785. static readonly EXPLICIT_MODE: number;
  17786. /** Spherical coordinates mode */
  17787. static readonly SPHERICAL_MODE: number;
  17788. /** Planar coordinates mode */
  17789. static readonly PLANAR_MODE: number;
  17790. /** Cubic coordinates mode */
  17791. static readonly CUBIC_MODE: number;
  17792. /** Projection coordinates mode */
  17793. static readonly PROJECTION_MODE: number;
  17794. /** Inverse Cubic coordinates mode */
  17795. static readonly SKYBOX_MODE: number;
  17796. /** Inverse Cubic coordinates mode */
  17797. static readonly INVCUBIC_MODE: number;
  17798. /** Equirectangular coordinates mode */
  17799. static readonly EQUIRECTANGULAR_MODE: number;
  17800. /** Equirectangular Fixed coordinates mode */
  17801. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  17802. /** Equirectangular Fixed Mirrored coordinates mode */
  17803. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  17804. /** Texture is not repeating outside of 0..1 UVs */
  17805. static readonly CLAMP_ADDRESSMODE: number;
  17806. /** Texture is repeating outside of 0..1 UVs */
  17807. static readonly WRAP_ADDRESSMODE: number;
  17808. /** Texture is repeating and mirrored */
  17809. static readonly MIRROR_ADDRESSMODE: number;
  17810. /**
  17811. * 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
  17812. */
  17813. static UseSerializedUrlIfAny: boolean;
  17814. /**
  17815. * Define the url of the texture.
  17816. */
  17817. url: Nullable<string>;
  17818. /**
  17819. * Define an offset on the texture to offset the u coordinates of the UVs
  17820. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17821. */
  17822. uOffset: number;
  17823. /**
  17824. * Define an offset on the texture to offset the v coordinates of the UVs
  17825. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  17826. */
  17827. vOffset: number;
  17828. /**
  17829. * Define an offset on the texture to scale the u coordinates of the UVs
  17830. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17831. */
  17832. uScale: number;
  17833. /**
  17834. * Define an offset on the texture to scale the v coordinates of the UVs
  17835. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  17836. */
  17837. vScale: number;
  17838. /**
  17839. * Define an offset on the texture to rotate around the u coordinates of the UVs
  17840. * @see http://doc.babylonjs.com/how_to/more_materials
  17841. */
  17842. uAng: number;
  17843. /**
  17844. * Define an offset on the texture to rotate around the v coordinates of the UVs
  17845. * @see http://doc.babylonjs.com/how_to/more_materials
  17846. */
  17847. vAng: number;
  17848. /**
  17849. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  17850. * @see http://doc.babylonjs.com/how_to/more_materials
  17851. */
  17852. wAng: number;
  17853. /**
  17854. * Defines the center of rotation (U)
  17855. */
  17856. uRotationCenter: number;
  17857. /**
  17858. * Defines the center of rotation (V)
  17859. */
  17860. vRotationCenter: number;
  17861. /**
  17862. * Defines the center of rotation (W)
  17863. */
  17864. wRotationCenter: number;
  17865. /**
  17866. * Are mip maps generated for this texture or not.
  17867. */
  17868. readonly noMipmap: boolean;
  17869. /**
  17870. * List of inspectable custom properties (used by the Inspector)
  17871. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  17872. */
  17873. inspectableCustomProperties: Nullable<IInspectable[]>;
  17874. private _noMipmap;
  17875. /** @hidden */ private _invertY: boolean;
  17876. private _rowGenerationMatrix;
  17877. private _cachedTextureMatrix;
  17878. private _projectionModeMatrix;
  17879. private _t0;
  17880. private _t1;
  17881. private _t2;
  17882. private _cachedUOffset;
  17883. private _cachedVOffset;
  17884. private _cachedUScale;
  17885. private _cachedVScale;
  17886. private _cachedUAng;
  17887. private _cachedVAng;
  17888. private _cachedWAng;
  17889. private _cachedProjectionMatrixId;
  17890. private _cachedCoordinatesMode;
  17891. /** @hidden */
  17892. protected _initialSamplingMode: number;
  17893. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  17894. private _deleteBuffer;
  17895. protected _format: Nullable<number>;
  17896. private _delayedOnLoad;
  17897. private _delayedOnError;
  17898. /**
  17899. * Observable triggered once the texture has been loaded.
  17900. */
  17901. onLoadObservable: Observable<Texture>;
  17902. protected _isBlocking: boolean;
  17903. /**
  17904. * Is the texture preventing material to render while loading.
  17905. * If false, a default texture will be used instead of the loading one during the preparation step.
  17906. */
  17907. isBlocking: boolean;
  17908. /**
  17909. * Get the current sampling mode associated with the texture.
  17910. */
  17911. readonly samplingMode: number;
  17912. /**
  17913. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  17914. */
  17915. readonly invertY: boolean;
  17916. /**
  17917. * Instantiates a new texture.
  17918. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  17919. * @see http://doc.babylonjs.com/babylon101/materials#texture
  17920. * @param url define the url of the picture to load as a texture
  17921. * @param scene define the scene the texture will belong to
  17922. * @param noMipmap define if the texture will require mip maps or not
  17923. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17924. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17925. * @param onLoad define a callback triggered when the texture has been loaded
  17926. * @param onError define a callback triggered when an error occurred during the loading session
  17927. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  17928. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  17929. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17930. */
  17931. 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);
  17932. /**
  17933. * Update the url (and optional buffer) of this texture if url was null during construction.
  17934. * @param url the url of the texture
  17935. * @param buffer the buffer of the texture (defaults to null)
  17936. * @param onLoad callback called when the texture is loaded (defaults to null)
  17937. */
  17938. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  17939. /**
  17940. * Finish the loading sequence of a texture flagged as delayed load.
  17941. * @hidden
  17942. */
  17943. delayLoad(): void;
  17944. private _prepareRowForTextureGeneration;
  17945. /**
  17946. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  17947. * @returns the transform matrix of the texture.
  17948. */
  17949. getTextureMatrix(): Matrix;
  17950. /**
  17951. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  17952. * @returns The reflection texture transform
  17953. */
  17954. getReflectionTextureMatrix(): Matrix;
  17955. /**
  17956. * Clones the texture.
  17957. * @returns the cloned texture
  17958. */
  17959. clone(): Texture;
  17960. /**
  17961. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  17962. * @returns The JSON representation of the texture
  17963. */
  17964. serialize(): any;
  17965. /**
  17966. * Get the current class name of the texture useful for serialization or dynamic coding.
  17967. * @returns "Texture"
  17968. */
  17969. getClassName(): string;
  17970. /**
  17971. * Dispose the texture and release its associated resources.
  17972. */
  17973. dispose(): void;
  17974. /**
  17975. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  17976. * @param parsedTexture Define the JSON representation of the texture
  17977. * @param scene Define the scene the parsed texture should be instantiated in
  17978. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  17979. * @returns The parsed texture if successful
  17980. */
  17981. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  17982. /**
  17983. * Creates a texture from its base 64 representation.
  17984. * @param data Define the base64 payload without the data: prefix
  17985. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  17986. * @param scene Define the scene the texture should belong to
  17987. * @param noMipmap Forces the texture to not create mip map information if true
  17988. * @param invertY define if the texture needs to be inverted on the y axis during loading
  17989. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  17990. * @param onLoad define a callback triggered when the texture has been loaded
  17991. * @param onError define a callback triggered when an error occurred during the loading session
  17992. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  17993. * @returns the created texture
  17994. */
  17995. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  17996. /**
  17997. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  17998. * @param data Define the base64 payload without the data: prefix
  17999. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18000. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18001. * @param scene Define the scene the texture should belong to
  18002. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18003. * @param noMipmap Forces the texture to not create mip map information if true
  18004. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18005. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18006. * @param onLoad define a callback triggered when the texture has been loaded
  18007. * @param onError define a callback triggered when an error occurred during the loading session
  18008. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18009. * @returns the created texture
  18010. */
  18011. 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;
  18012. }
  18013. }
  18014. declare module BABYLON {
  18015. interface Engine {
  18016. /**
  18017. * Creates a raw texture
  18018. * @param data defines the data to store in the texture
  18019. * @param width defines the width of the texture
  18020. * @param height defines the height of the texture
  18021. * @param format defines the format of the data
  18022. * @param generateMipMaps defines if the engine should generate the mip levels
  18023. * @param invertY defines if data must be stored with Y axis inverted
  18024. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18025. * @param compression defines the compression used (null by default)
  18026. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18027. * @returns the raw texture inside an InternalTexture
  18028. */
  18029. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18030. /**
  18031. * Update a raw texture
  18032. * @param texture defines the texture to update
  18033. * @param data defines the data to store in the texture
  18034. * @param format defines the format of the data
  18035. * @param invertY defines if data must be stored with Y axis inverted
  18036. */
  18037. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18038. /**
  18039. * Update a raw texture
  18040. * @param texture defines the texture to update
  18041. * @param data defines the data to store in the texture
  18042. * @param format defines the format of the data
  18043. * @param invertY defines if data must be stored with Y axis inverted
  18044. * @param compression defines the compression used (null by default)
  18045. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18046. */
  18047. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18048. /**
  18049. * Creates a new raw cube texture
  18050. * @param data defines the array of data to use to create each face
  18051. * @param size defines the size of the textures
  18052. * @param format defines the format of the data
  18053. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18054. * @param generateMipMaps defines if the engine should generate the mip levels
  18055. * @param invertY defines if data must be stored with Y axis inverted
  18056. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18057. * @param compression defines the compression used (null by default)
  18058. * @returns the cube texture as an InternalTexture
  18059. */
  18060. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18061. /**
  18062. * Update a raw cube texture
  18063. * @param texture defines the texture to udpdate
  18064. * @param data defines the data to store
  18065. * @param format defines the data format
  18066. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18067. * @param invertY defines if data must be stored with Y axis inverted
  18068. */
  18069. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18070. /**
  18071. * Update a raw cube texture
  18072. * @param texture defines the texture to udpdate
  18073. * @param data defines the data to store
  18074. * @param format defines the data format
  18075. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18076. * @param invertY defines if data must be stored with Y axis inverted
  18077. * @param compression defines the compression used (null by default)
  18078. */
  18079. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18080. /**
  18081. * Update a raw cube texture
  18082. * @param texture defines the texture to udpdate
  18083. * @param data defines the data to store
  18084. * @param format defines the data format
  18085. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18086. * @param invertY defines if data must be stored with Y axis inverted
  18087. * @param compression defines the compression used (null by default)
  18088. * @param level defines which level of the texture to update
  18089. */
  18090. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18091. /**
  18092. * Creates a new raw cube texture from a specified url
  18093. * @param url defines the url where the data is located
  18094. * @param scene defines the current scene
  18095. * @param size defines the size of the textures
  18096. * @param format defines the format of the data
  18097. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18098. * @param noMipmap defines if the engine should avoid generating the mip levels
  18099. * @param callback defines a callback used to extract texture data from loaded data
  18100. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18101. * @param onLoad defines a callback called when texture is loaded
  18102. * @param onError defines a callback called if there is an error
  18103. * @returns the cube texture as an InternalTexture
  18104. */
  18105. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  18106. /**
  18107. * Creates a new raw cube texture from a specified url
  18108. * @param url defines the url where the data is located
  18109. * @param scene defines the current scene
  18110. * @param size defines the size of the textures
  18111. * @param format defines the format of the data
  18112. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18113. * @param noMipmap defines if the engine should avoid generating the mip levels
  18114. * @param callback defines a callback used to extract texture data from loaded data
  18115. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18116. * @param onLoad defines a callback called when texture is loaded
  18117. * @param onError defines a callback called if there is an error
  18118. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18119. * @param invertY defines if data must be stored with Y axis inverted
  18120. * @returns the cube texture as an InternalTexture
  18121. */
  18122. 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;
  18123. /**
  18124. * Creates a new raw 3D texture
  18125. * @param data defines the data used to create the texture
  18126. * @param width defines the width of the texture
  18127. * @param height defines the height of the texture
  18128. * @param depth defines the depth of the texture
  18129. * @param format defines the format of the texture
  18130. * @param generateMipMaps defines if the engine must generate mip levels
  18131. * @param invertY defines if data must be stored with Y axis inverted
  18132. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18133. * @param compression defines the compressed used (can be null)
  18134. * @param textureType defines the compressed used (can be null)
  18135. * @returns a new raw 3D texture (stored in an InternalTexture)
  18136. */
  18137. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18138. /**
  18139. * Update a raw 3D texture
  18140. * @param texture defines the texture to update
  18141. * @param data defines the data to store
  18142. * @param format defines the data format
  18143. * @param invertY defines if data must be stored with Y axis inverted
  18144. */
  18145. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18146. /**
  18147. * Update a raw 3D texture
  18148. * @param texture defines the texture to update
  18149. * @param data defines the data to store
  18150. * @param format defines the data format
  18151. * @param invertY defines if data must be stored with Y axis inverted
  18152. * @param compression defines the used compression (can be null)
  18153. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18154. */
  18155. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18156. }
  18157. }
  18158. declare module BABYLON {
  18159. /**
  18160. * Raw texture can help creating a texture directly from an array of data.
  18161. * This can be super useful if you either get the data from an uncompressed source or
  18162. * if you wish to create your texture pixel by pixel.
  18163. */
  18164. export class RawTexture extends Texture {
  18165. /**
  18166. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18167. */
  18168. format: number;
  18169. private _engine;
  18170. /**
  18171. * Instantiates a new RawTexture.
  18172. * Raw texture can help creating a texture directly from an array of data.
  18173. * This can be super useful if you either get the data from an uncompressed source or
  18174. * if you wish to create your texture pixel by pixel.
  18175. * @param data define the array of data to use to create the texture
  18176. * @param width define the width of the texture
  18177. * @param height define the height of the texture
  18178. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18179. * @param scene define the scene the texture belongs to
  18180. * @param generateMipMaps define whether mip maps should be generated or not
  18181. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18182. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18183. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18184. */
  18185. constructor(data: ArrayBufferView, width: number, height: number,
  18186. /**
  18187. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18188. */
  18189. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18190. /**
  18191. * Updates the texture underlying data.
  18192. * @param data Define the new data of the texture
  18193. */
  18194. update(data: ArrayBufferView): void;
  18195. /**
  18196. * Creates a luminance texture from some data.
  18197. * @param data Define the texture data
  18198. * @param width Define the width of the texture
  18199. * @param height Define the height of the texture
  18200. * @param scene Define the scene the texture belongs to
  18201. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18202. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18203. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18204. * @returns the luminance texture
  18205. */
  18206. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18207. /**
  18208. * Creates a luminance alpha texture from some data.
  18209. * @param data Define the texture data
  18210. * @param width Define the width of the texture
  18211. * @param height Define the height of the texture
  18212. * @param scene Define the scene the texture belongs to
  18213. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18214. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18215. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18216. * @returns the luminance alpha texture
  18217. */
  18218. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18219. /**
  18220. * Creates an alpha texture from some data.
  18221. * @param data Define the texture data
  18222. * @param width Define the width of the texture
  18223. * @param height Define the height of the texture
  18224. * @param scene Define the scene the texture belongs to
  18225. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18226. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18227. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18228. * @returns the alpha texture
  18229. */
  18230. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18231. /**
  18232. * Creates a RGB texture from some data.
  18233. * @param data Define the texture data
  18234. * @param width Define the width of the texture
  18235. * @param height Define the height of the texture
  18236. * @param scene Define the scene the texture belongs to
  18237. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18238. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18239. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18240. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18241. * @returns the RGB alpha texture
  18242. */
  18243. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18244. /**
  18245. * Creates a RGBA texture from some data.
  18246. * @param data Define the texture data
  18247. * @param width Define the width of the texture
  18248. * @param height Define the height of the texture
  18249. * @param scene Define the scene the texture belongs to
  18250. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18251. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18252. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18253. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18254. * @returns the RGBA texture
  18255. */
  18256. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18257. /**
  18258. * Creates a R texture from some data.
  18259. * @param data Define the texture data
  18260. * @param width Define the width of the texture
  18261. * @param height Define the height of the texture
  18262. * @param scene Define the scene the texture belongs to
  18263. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18266. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18267. * @returns the R texture
  18268. */
  18269. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18270. }
  18271. }
  18272. declare module BABYLON {
  18273. /**
  18274. * Defines a runtime animation
  18275. */
  18276. export class RuntimeAnimation {
  18277. private _events;
  18278. /**
  18279. * The current frame of the runtime animation
  18280. */
  18281. private _currentFrame;
  18282. /**
  18283. * The animation used by the runtime animation
  18284. */
  18285. private _animation;
  18286. /**
  18287. * The target of the runtime animation
  18288. */
  18289. private _target;
  18290. /**
  18291. * The initiating animatable
  18292. */
  18293. private _host;
  18294. /**
  18295. * The original value of the runtime animation
  18296. */
  18297. private _originalValue;
  18298. /**
  18299. * The original blend value of the runtime animation
  18300. */
  18301. private _originalBlendValue;
  18302. /**
  18303. * The offsets cache of the runtime animation
  18304. */
  18305. private _offsetsCache;
  18306. /**
  18307. * The high limits cache of the runtime animation
  18308. */
  18309. private _highLimitsCache;
  18310. /**
  18311. * Specifies if the runtime animation has been stopped
  18312. */
  18313. private _stopped;
  18314. /**
  18315. * The blending factor of the runtime animation
  18316. */
  18317. private _blendingFactor;
  18318. /**
  18319. * The BabylonJS scene
  18320. */
  18321. private _scene;
  18322. /**
  18323. * The current value of the runtime animation
  18324. */
  18325. private _currentValue;
  18326. /** @hidden */ private _animationState: _IAnimationState;
  18327. /**
  18328. * The active target of the runtime animation
  18329. */
  18330. private _activeTargets;
  18331. private _currentActiveTarget;
  18332. private _directTarget;
  18333. /**
  18334. * The target path of the runtime animation
  18335. */
  18336. private _targetPath;
  18337. /**
  18338. * The weight of the runtime animation
  18339. */
  18340. private _weight;
  18341. /**
  18342. * The ratio offset of the runtime animation
  18343. */
  18344. private _ratioOffset;
  18345. /**
  18346. * The previous delay of the runtime animation
  18347. */
  18348. private _previousDelay;
  18349. /**
  18350. * The previous ratio of the runtime animation
  18351. */
  18352. private _previousRatio;
  18353. private _enableBlending;
  18354. private _keys;
  18355. private _minFrame;
  18356. private _maxFrame;
  18357. private _minValue;
  18358. private _maxValue;
  18359. private _targetIsArray;
  18360. /**
  18361. * Gets the current frame of the runtime animation
  18362. */
  18363. readonly currentFrame: number;
  18364. /**
  18365. * Gets the weight of the runtime animation
  18366. */
  18367. readonly weight: number;
  18368. /**
  18369. * Gets the current value of the runtime animation
  18370. */
  18371. readonly currentValue: any;
  18372. /**
  18373. * Gets the target path of the runtime animation
  18374. */
  18375. readonly targetPath: string;
  18376. /**
  18377. * Gets the actual target of the runtime animation
  18378. */
  18379. readonly target: any;
  18380. /** @hidden */ private _onLoop: () => void;
  18381. /**
  18382. * Create a new RuntimeAnimation object
  18383. * @param target defines the target of the animation
  18384. * @param animation defines the source animation object
  18385. * @param scene defines the hosting scene
  18386. * @param host defines the initiating Animatable
  18387. */
  18388. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  18389. private _preparePath;
  18390. /**
  18391. * Gets the animation from the runtime animation
  18392. */
  18393. readonly animation: Animation;
  18394. /**
  18395. * Resets the runtime animation to the beginning
  18396. * @param restoreOriginal defines whether to restore the target property to the original value
  18397. */
  18398. reset(restoreOriginal?: boolean): void;
  18399. /**
  18400. * Specifies if the runtime animation is stopped
  18401. * @returns Boolean specifying if the runtime animation is stopped
  18402. */
  18403. isStopped(): boolean;
  18404. /**
  18405. * Disposes of the runtime animation
  18406. */
  18407. dispose(): void;
  18408. /**
  18409. * Apply the interpolated value to the target
  18410. * @param currentValue defines the value computed by the animation
  18411. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  18412. */
  18413. setValue(currentValue: any, weight: number): void;
  18414. private _getOriginalValues;
  18415. private _setValue;
  18416. /**
  18417. * Gets the loop pmode of the runtime animation
  18418. * @returns Loop Mode
  18419. */
  18420. private _getCorrectLoopMode;
  18421. /**
  18422. * Move the current animation to a given frame
  18423. * @param frame defines the frame to move to
  18424. */
  18425. goToFrame(frame: number): void;
  18426. /**
  18427. * @hidden Internal use only
  18428. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  18429. /**
  18430. * Execute the current animation
  18431. * @param delay defines the delay to add to the current frame
  18432. * @param from defines the lower bound of the animation range
  18433. * @param to defines the upper bound of the animation range
  18434. * @param loop defines if the current animation must loop
  18435. * @param speedRatio defines the current speed ratio
  18436. * @param weight defines the weight of the animation (default is -1 so no weight)
  18437. * @param onLoop optional callback called when animation loops
  18438. * @returns a boolean indicating if the animation is running
  18439. */
  18440. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  18441. }
  18442. }
  18443. declare module BABYLON {
  18444. /**
  18445. * Class used to store an actual running animation
  18446. */
  18447. export class Animatable {
  18448. /** defines the target object */
  18449. target: any;
  18450. /** defines the starting frame number (default is 0) */
  18451. fromFrame: number;
  18452. /** defines the ending frame number (default is 100) */
  18453. toFrame: number;
  18454. /** defines if the animation must loop (default is false) */
  18455. loopAnimation: boolean;
  18456. /** defines a callback to call when animation ends if it is not looping */
  18457. onAnimationEnd?: (() => void) | null | undefined;
  18458. /** defines a callback to call when animation loops */
  18459. onAnimationLoop?: (() => void) | null | undefined;
  18460. private _localDelayOffset;
  18461. private _pausedDelay;
  18462. private _runtimeAnimations;
  18463. private _paused;
  18464. private _scene;
  18465. private _speedRatio;
  18466. private _weight;
  18467. private _syncRoot;
  18468. /**
  18469. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  18470. * This will only apply for non looping animation (default is true)
  18471. */
  18472. disposeOnEnd: boolean;
  18473. /**
  18474. * Gets a boolean indicating if the animation has started
  18475. */
  18476. animationStarted: boolean;
  18477. /**
  18478. * Observer raised when the animation ends
  18479. */
  18480. onAnimationEndObservable: Observable<Animatable>;
  18481. /**
  18482. * Observer raised when the animation loops
  18483. */
  18484. onAnimationLoopObservable: Observable<Animatable>;
  18485. /**
  18486. * Gets the root Animatable used to synchronize and normalize animations
  18487. */
  18488. readonly syncRoot: Nullable<Animatable>;
  18489. /**
  18490. * Gets the current frame of the first RuntimeAnimation
  18491. * Used to synchronize Animatables
  18492. */
  18493. readonly masterFrame: number;
  18494. /**
  18495. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  18496. */
  18497. weight: number;
  18498. /**
  18499. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  18500. */
  18501. speedRatio: number;
  18502. /**
  18503. * Creates a new Animatable
  18504. * @param scene defines the hosting scene
  18505. * @param target defines the target object
  18506. * @param fromFrame defines the starting frame number (default is 0)
  18507. * @param toFrame defines the ending frame number (default is 100)
  18508. * @param loopAnimation defines if the animation must loop (default is false)
  18509. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  18510. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  18511. * @param animations defines a group of animation to add to the new Animatable
  18512. * @param onAnimationLoop defines a callback to call when animation loops
  18513. */
  18514. constructor(scene: Scene,
  18515. /** defines the target object */
  18516. target: any,
  18517. /** defines the starting frame number (default is 0) */
  18518. fromFrame?: number,
  18519. /** defines the ending frame number (default is 100) */
  18520. toFrame?: number,
  18521. /** defines if the animation must loop (default is false) */
  18522. loopAnimation?: boolean, speedRatio?: number,
  18523. /** defines a callback to call when animation ends if it is not looping */
  18524. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  18525. /** defines a callback to call when animation loops */
  18526. onAnimationLoop?: (() => void) | null | undefined);
  18527. /**
  18528. * Synchronize and normalize current Animatable with a source Animatable
  18529. * This is useful when using animation weights and when animations are not of the same length
  18530. * @param root defines the root Animatable to synchronize with
  18531. * @returns the current Animatable
  18532. */
  18533. syncWith(root: Animatable): Animatable;
  18534. /**
  18535. * Gets the list of runtime animations
  18536. * @returns an array of RuntimeAnimation
  18537. */
  18538. getAnimations(): RuntimeAnimation[];
  18539. /**
  18540. * Adds more animations to the current animatable
  18541. * @param target defines the target of the animations
  18542. * @param animations defines the new animations to add
  18543. */
  18544. appendAnimations(target: any, animations: Animation[]): void;
  18545. /**
  18546. * Gets the source animation for a specific property
  18547. * @param property defines the propertyu to look for
  18548. * @returns null or the source animation for the given property
  18549. */
  18550. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  18551. /**
  18552. * Gets the runtime animation for a specific property
  18553. * @param property defines the propertyu to look for
  18554. * @returns null or the runtime animation for the given property
  18555. */
  18556. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  18557. /**
  18558. * Resets the animatable to its original state
  18559. */
  18560. reset(): void;
  18561. /**
  18562. * Allows the animatable to blend with current running animations
  18563. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18564. * @param blendingSpeed defines the blending speed to use
  18565. */
  18566. enableBlending(blendingSpeed: number): void;
  18567. /**
  18568. * Disable animation blending
  18569. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18570. */
  18571. disableBlending(): void;
  18572. /**
  18573. * Jump directly to a given frame
  18574. * @param frame defines the frame to jump to
  18575. */
  18576. goToFrame(frame: number): void;
  18577. /**
  18578. * Pause the animation
  18579. */
  18580. pause(): void;
  18581. /**
  18582. * Restart the animation
  18583. */
  18584. restart(): void;
  18585. private _raiseOnAnimationEnd;
  18586. /**
  18587. * Stop and delete the current animation
  18588. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  18589. * @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)
  18590. */
  18591. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  18592. /**
  18593. * Wait asynchronously for the animation to end
  18594. * @returns a promise which will be fullfilled when the animation ends
  18595. */
  18596. waitAsync(): Promise<Animatable>;
  18597. /** @hidden */ private _animate(delay: number): boolean;
  18598. }
  18599. interface Scene {
  18600. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  18601. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  18602. totalWeight: number;
  18603. animations: RuntimeAnimation[];
  18604. originalValue: Matrix;
  18605. }): any;
  18606. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  18607. totalWeight: number;
  18608. animations: RuntimeAnimation[];
  18609. originalValue: Quaternion;
  18610. }, refQuaternion: Quaternion): Quaternion;
  18611. /** @hidden */ private _processLateAnimationBindings(): void;
  18612. /**
  18613. * Will start the animation sequence of a given target
  18614. * @param target defines the target
  18615. * @param from defines from which frame should animation start
  18616. * @param to defines until which frame should animation run.
  18617. * @param weight defines the weight to apply to the animation (1.0 by default)
  18618. * @param loop defines if the animation loops
  18619. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18620. * @param onAnimationEnd defines the function to be executed when the animation ends
  18621. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18622. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18623. * @param onAnimationLoop defines the callback to call when an animation loops
  18624. * @returns the animatable object created for this animation
  18625. */
  18626. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18627. /**
  18628. * Will start the animation sequence of a given target
  18629. * @param target defines the target
  18630. * @param from defines from which frame should animation start
  18631. * @param to defines until which frame should animation run.
  18632. * @param loop defines if the animation loops
  18633. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18634. * @param onAnimationEnd defines the function to be executed when the animation ends
  18635. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18636. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18637. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  18638. * @param onAnimationLoop defines the callback to call when an animation loops
  18639. * @returns the animatable object created for this animation
  18640. */
  18641. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  18642. /**
  18643. * Will start the animation sequence of a given target and its hierarchy
  18644. * @param target defines the target
  18645. * @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.
  18646. * @param from defines from which frame should animation start
  18647. * @param to defines until which frame should animation run.
  18648. * @param loop defines if the animation loops
  18649. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  18650. * @param onAnimationEnd defines the function to be executed when the animation ends
  18651. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  18652. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  18653. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  18654. * @param onAnimationLoop defines the callback to call when an animation loops
  18655. * @returns the list of created animatables
  18656. */
  18657. 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[];
  18658. /**
  18659. * Begin a new animation on a given node
  18660. * @param target defines the target where the animation will take place
  18661. * @param animations defines the list of animations to start
  18662. * @param from defines the initial value
  18663. * @param to defines the final value
  18664. * @param loop defines if you want animation to loop (off by default)
  18665. * @param speedRatio defines the speed ratio to apply to all animations
  18666. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18667. * @param onAnimationLoop defines the callback to call when an animation loops
  18668. * @returns the list of created animatables
  18669. */
  18670. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  18671. /**
  18672. * Begin a new animation on a given node and its hierarchy
  18673. * @param target defines the root node where the animation will take place
  18674. * @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.
  18675. * @param animations defines the list of animations to start
  18676. * @param from defines the initial value
  18677. * @param to defines the final value
  18678. * @param loop defines if you want animation to loop (off by default)
  18679. * @param speedRatio defines the speed ratio to apply to all animations
  18680. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  18681. * @param onAnimationLoop defines the callback to call when an animation loops
  18682. * @returns the list of animatables created for all nodes
  18683. */
  18684. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  18685. /**
  18686. * Gets the animatable associated with a specific target
  18687. * @param target defines the target of the animatable
  18688. * @returns the required animatable if found
  18689. */
  18690. getAnimatableByTarget(target: any): Nullable<Animatable>;
  18691. /**
  18692. * Gets all animatables associated with a given target
  18693. * @param target defines the target to look animatables for
  18694. * @returns an array of Animatables
  18695. */
  18696. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  18697. /**
  18698. * Stops and removes all animations that have been applied to the scene
  18699. */
  18700. stopAllAnimations(): void;
  18701. }
  18702. interface Bone {
  18703. /**
  18704. * Copy an animation range from another bone
  18705. * @param source defines the source bone
  18706. * @param rangeName defines the range name to copy
  18707. * @param frameOffset defines the frame offset
  18708. * @param rescaleAsRequired defines if rescaling must be applied if required
  18709. * @param skelDimensionsRatio defines the scaling ratio
  18710. * @returns true if operation was successful
  18711. */
  18712. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  18713. }
  18714. }
  18715. declare module BABYLON {
  18716. /**
  18717. * Class used to handle skinning animations
  18718. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  18719. */
  18720. export class Skeleton implements IAnimatable {
  18721. /** defines the skeleton name */
  18722. name: string;
  18723. /** defines the skeleton Id */
  18724. id: string;
  18725. /**
  18726. * Defines the list of child bones
  18727. */
  18728. bones: Bone[];
  18729. /**
  18730. * Defines an estimate of the dimension of the skeleton at rest
  18731. */
  18732. dimensionsAtRest: Vector3;
  18733. /**
  18734. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  18735. */
  18736. needInitialSkinMatrix: boolean;
  18737. /**
  18738. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  18739. */
  18740. overrideMesh: Nullable<AbstractMesh>;
  18741. /**
  18742. * Gets the list of animations attached to this skeleton
  18743. */
  18744. animations: Array<Animation>;
  18745. private _scene;
  18746. private _isDirty;
  18747. private _transformMatrices;
  18748. private _transformMatrixTexture;
  18749. private _meshesWithPoseMatrix;
  18750. private _animatables;
  18751. private _identity;
  18752. private _synchronizedWithMesh;
  18753. private _ranges;
  18754. private _lastAbsoluteTransformsUpdateId;
  18755. private _canUseTextureForBones;
  18756. private _uniqueId;
  18757. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  18758. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  18759. /**
  18760. * Specifies if the skeleton should be serialized
  18761. */
  18762. doNotSerialize: boolean;
  18763. private _useTextureToStoreBoneMatrices;
  18764. /**
  18765. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  18766. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  18767. */
  18768. useTextureToStoreBoneMatrices: boolean;
  18769. private _animationPropertiesOverride;
  18770. /**
  18771. * Gets or sets the animation properties override
  18772. */
  18773. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18774. /**
  18775. * List of inspectable custom properties (used by the Inspector)
  18776. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18777. */
  18778. inspectableCustomProperties: IInspectable[];
  18779. /**
  18780. * An observable triggered before computing the skeleton's matrices
  18781. */
  18782. onBeforeComputeObservable: Observable<Skeleton>;
  18783. /**
  18784. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  18785. */
  18786. readonly isUsingTextureForMatrices: boolean;
  18787. /**
  18788. * Gets the unique ID of this skeleton
  18789. */
  18790. readonly uniqueId: number;
  18791. /**
  18792. * Creates a new skeleton
  18793. * @param name defines the skeleton name
  18794. * @param id defines the skeleton Id
  18795. * @param scene defines the hosting scene
  18796. */
  18797. constructor(
  18798. /** defines the skeleton name */
  18799. name: string,
  18800. /** defines the skeleton Id */
  18801. id: string, scene: Scene);
  18802. /**
  18803. * Gets the current object class name.
  18804. * @return the class name
  18805. */
  18806. getClassName(): string;
  18807. /**
  18808. * Returns an array containing the root bones
  18809. * @returns an array containing the root bones
  18810. */
  18811. getChildren(): Array<Bone>;
  18812. /**
  18813. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  18814. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  18815. * @returns a Float32Array containing matrices data
  18816. */
  18817. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  18818. /**
  18819. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  18820. * @returns a raw texture containing the data
  18821. */
  18822. getTransformMatrixTexture(): Nullable<RawTexture>;
  18823. /**
  18824. * Gets the current hosting scene
  18825. * @returns a scene object
  18826. */
  18827. getScene(): Scene;
  18828. /**
  18829. * Gets a string representing the current skeleton data
  18830. * @param fullDetails defines a boolean indicating if we want a verbose version
  18831. * @returns a string representing the current skeleton data
  18832. */
  18833. toString(fullDetails?: boolean): string;
  18834. /**
  18835. * Get bone's index searching by name
  18836. * @param name defines bone's name to search for
  18837. * @return the indice of the bone. Returns -1 if not found
  18838. */
  18839. getBoneIndexByName(name: string): number;
  18840. /**
  18841. * Creater a new animation range
  18842. * @param name defines the name of the range
  18843. * @param from defines the start key
  18844. * @param to defines the end key
  18845. */
  18846. createAnimationRange(name: string, from: number, to: number): void;
  18847. /**
  18848. * Delete a specific animation range
  18849. * @param name defines the name of the range
  18850. * @param deleteFrames defines if frames must be removed as well
  18851. */
  18852. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  18853. /**
  18854. * Gets a specific animation range
  18855. * @param name defines the name of the range to look for
  18856. * @returns the requested animation range or null if not found
  18857. */
  18858. getAnimationRange(name: string): Nullable<AnimationRange>;
  18859. /**
  18860. * Gets the list of all animation ranges defined on this skeleton
  18861. * @returns an array
  18862. */
  18863. getAnimationRanges(): Nullable<AnimationRange>[];
  18864. /**
  18865. * Copy animation range from a source skeleton.
  18866. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  18867. * @param source defines the source skeleton
  18868. * @param name defines the name of the range to copy
  18869. * @param rescaleAsRequired defines if rescaling must be applied if required
  18870. * @returns true if operation was successful
  18871. */
  18872. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  18873. /**
  18874. * Forces the skeleton to go to rest pose
  18875. */
  18876. returnToRest(): void;
  18877. private _getHighestAnimationFrame;
  18878. /**
  18879. * Begin a specific animation range
  18880. * @param name defines the name of the range to start
  18881. * @param loop defines if looping must be turned on (false by default)
  18882. * @param speedRatio defines the speed ratio to apply (1 by default)
  18883. * @param onAnimationEnd defines a callback which will be called when animation will end
  18884. * @returns a new animatable
  18885. */
  18886. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  18887. /** @hidden */ private _markAsDirty(): void;
  18888. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18889. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  18890. private _computeTransformMatrices;
  18891. /**
  18892. * Build all resources required to render a skeleton
  18893. */
  18894. prepare(): void;
  18895. /**
  18896. * Gets the list of animatables currently running for this skeleton
  18897. * @returns an array of animatables
  18898. */
  18899. getAnimatables(): IAnimatable[];
  18900. /**
  18901. * Clone the current skeleton
  18902. * @param name defines the name of the new skeleton
  18903. * @param id defines the id of the new skeleton
  18904. * @returns the new skeleton
  18905. */
  18906. clone(name: string, id: string): Skeleton;
  18907. /**
  18908. * Enable animation blending for this skeleton
  18909. * @param blendingSpeed defines the blending speed to apply
  18910. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  18911. */
  18912. enableBlending(blendingSpeed?: number): void;
  18913. /**
  18914. * Releases all resources associated with the current skeleton
  18915. */
  18916. dispose(): void;
  18917. /**
  18918. * Serialize the skeleton in a JSON object
  18919. * @returns a JSON object
  18920. */
  18921. serialize(): any;
  18922. /**
  18923. * Creates a new skeleton from serialized data
  18924. * @param parsedSkeleton defines the serialized data
  18925. * @param scene defines the hosting scene
  18926. * @returns a new skeleton
  18927. */
  18928. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  18929. /**
  18930. * Compute all node absolute transforms
  18931. * @param forceUpdate defines if computation must be done even if cache is up to date
  18932. */
  18933. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  18934. /**
  18935. * Gets the root pose matrix
  18936. * @returns a matrix
  18937. */
  18938. getPoseMatrix(): Nullable<Matrix>;
  18939. /**
  18940. * Sorts bones per internal index
  18941. */
  18942. sortBones(): void;
  18943. private _sortBones;
  18944. }
  18945. }
  18946. declare module BABYLON {
  18947. /**
  18948. * Defines a target to use with MorphTargetManager
  18949. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  18950. */
  18951. export class MorphTarget implements IAnimatable {
  18952. /** defines the name of the target */
  18953. name: string;
  18954. /**
  18955. * Gets or sets the list of animations
  18956. */
  18957. animations: Animation[];
  18958. private _scene;
  18959. private _positions;
  18960. private _normals;
  18961. private _tangents;
  18962. private _influence;
  18963. /**
  18964. * Observable raised when the influence changes
  18965. */
  18966. onInfluenceChanged: Observable<boolean>;
  18967. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  18968. /**
  18969. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  18970. */
  18971. influence: number;
  18972. /**
  18973. * Gets or sets the id of the morph Target
  18974. */
  18975. id: string;
  18976. private _animationPropertiesOverride;
  18977. /**
  18978. * Gets or sets the animation properties override
  18979. */
  18980. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  18981. /**
  18982. * Creates a new MorphTarget
  18983. * @param name defines the name of the target
  18984. * @param influence defines the influence to use
  18985. * @param scene defines the scene the morphtarget belongs to
  18986. */
  18987. constructor(
  18988. /** defines the name of the target */
  18989. name: string, influence?: number, scene?: Nullable<Scene>);
  18990. /**
  18991. * Gets a boolean defining if the target contains position data
  18992. */
  18993. readonly hasPositions: boolean;
  18994. /**
  18995. * Gets a boolean defining if the target contains normal data
  18996. */
  18997. readonly hasNormals: boolean;
  18998. /**
  18999. * Gets a boolean defining if the target contains tangent data
  19000. */
  19001. readonly hasTangents: boolean;
  19002. /**
  19003. * Affects position data to this target
  19004. * @param data defines the position data to use
  19005. */
  19006. setPositions(data: Nullable<FloatArray>): void;
  19007. /**
  19008. * Gets the position data stored in this target
  19009. * @returns a FloatArray containing the position data (or null if not present)
  19010. */
  19011. getPositions(): Nullable<FloatArray>;
  19012. /**
  19013. * Affects normal data to this target
  19014. * @param data defines the normal data to use
  19015. */
  19016. setNormals(data: Nullable<FloatArray>): void;
  19017. /**
  19018. * Gets the normal data stored in this target
  19019. * @returns a FloatArray containing the normal data (or null if not present)
  19020. */
  19021. getNormals(): Nullable<FloatArray>;
  19022. /**
  19023. * Affects tangent data to this target
  19024. * @param data defines the tangent data to use
  19025. */
  19026. setTangents(data: Nullable<FloatArray>): void;
  19027. /**
  19028. * Gets the tangent data stored in this target
  19029. * @returns a FloatArray containing the tangent data (or null if not present)
  19030. */
  19031. getTangents(): Nullable<FloatArray>;
  19032. /**
  19033. * Serializes the current target into a Serialization object
  19034. * @returns the serialized object
  19035. */
  19036. serialize(): any;
  19037. /**
  19038. * Returns the string "MorphTarget"
  19039. * @returns "MorphTarget"
  19040. */
  19041. getClassName(): string;
  19042. /**
  19043. * Creates a new target from serialized data
  19044. * @param serializationObject defines the serialized data to use
  19045. * @returns a new MorphTarget
  19046. */
  19047. static Parse(serializationObject: any): MorphTarget;
  19048. /**
  19049. * Creates a MorphTarget from mesh data
  19050. * @param mesh defines the source mesh
  19051. * @param name defines the name to use for the new target
  19052. * @param influence defines the influence to attach to the target
  19053. * @returns a new MorphTarget
  19054. */
  19055. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19056. }
  19057. }
  19058. declare module BABYLON {
  19059. /**
  19060. * This class is used to deform meshes using morphing between different targets
  19061. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19062. */
  19063. export class MorphTargetManager {
  19064. private _targets;
  19065. private _targetInfluenceChangedObservers;
  19066. private _targetDataLayoutChangedObservers;
  19067. private _activeTargets;
  19068. private _scene;
  19069. private _influences;
  19070. private _supportsNormals;
  19071. private _supportsTangents;
  19072. private _vertexCount;
  19073. private _uniqueId;
  19074. private _tempInfluences;
  19075. /**
  19076. * Creates a new MorphTargetManager
  19077. * @param scene defines the current scene
  19078. */
  19079. constructor(scene?: Nullable<Scene>);
  19080. /**
  19081. * Gets the unique ID of this manager
  19082. */
  19083. readonly uniqueId: number;
  19084. /**
  19085. * Gets the number of vertices handled by this manager
  19086. */
  19087. readonly vertexCount: number;
  19088. /**
  19089. * Gets a boolean indicating if this manager supports morphing of normals
  19090. */
  19091. readonly supportsNormals: boolean;
  19092. /**
  19093. * Gets a boolean indicating if this manager supports morphing of tangents
  19094. */
  19095. readonly supportsTangents: boolean;
  19096. /**
  19097. * Gets the number of targets stored in this manager
  19098. */
  19099. readonly numTargets: number;
  19100. /**
  19101. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19102. */
  19103. readonly numInfluencers: number;
  19104. /**
  19105. * Gets the list of influences (one per target)
  19106. */
  19107. readonly influences: Float32Array;
  19108. /**
  19109. * Gets the active target at specified index. An active target is a target with an influence > 0
  19110. * @param index defines the index to check
  19111. * @returns the requested target
  19112. */
  19113. getActiveTarget(index: number): MorphTarget;
  19114. /**
  19115. * Gets the target at specified index
  19116. * @param index defines the index to check
  19117. * @returns the requested target
  19118. */
  19119. getTarget(index: number): MorphTarget;
  19120. /**
  19121. * Add a new target to this manager
  19122. * @param target defines the target to add
  19123. */
  19124. addTarget(target: MorphTarget): void;
  19125. /**
  19126. * Removes a target from the manager
  19127. * @param target defines the target to remove
  19128. */
  19129. removeTarget(target: MorphTarget): void;
  19130. /**
  19131. * Serializes the current manager into a Serialization object
  19132. * @returns the serialized object
  19133. */
  19134. serialize(): any;
  19135. private _syncActiveTargets;
  19136. /**
  19137. * Syncrhonize the targets with all the meshes using this morph target manager
  19138. */
  19139. synchronize(): void;
  19140. /**
  19141. * Creates a new MorphTargetManager from serialized data
  19142. * @param serializationObject defines the serialized data
  19143. * @param scene defines the hosting scene
  19144. * @returns the new MorphTargetManager
  19145. */
  19146. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19147. }
  19148. }
  19149. declare module BABYLON {
  19150. /**
  19151. * Class used to represent a specific level of detail of a mesh
  19152. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  19153. */
  19154. export class MeshLODLevel {
  19155. /** Defines the distance where this level should star being displayed */
  19156. distance: number;
  19157. /** Defines the mesh to use to render this level */
  19158. mesh: Nullable<Mesh>;
  19159. /**
  19160. * Creates a new LOD level
  19161. * @param distance defines the distance where this level should star being displayed
  19162. * @param mesh defines the mesh to use to render this level
  19163. */
  19164. constructor(
  19165. /** Defines the distance where this level should star being displayed */
  19166. distance: number,
  19167. /** Defines the mesh to use to render this level */
  19168. mesh: Nullable<Mesh>);
  19169. }
  19170. }
  19171. declare module BABYLON {
  19172. /**
  19173. * Mesh representing the gorund
  19174. */
  19175. export class GroundMesh extends Mesh {
  19176. /** If octree should be generated */
  19177. generateOctree: boolean;
  19178. private _heightQuads;
  19179. /** @hidden */ private _subdivisionsX: number;
  19180. /** @hidden */ private _subdivisionsY: number;
  19181. /** @hidden */ private _width: number;
  19182. /** @hidden */ private _height: number;
  19183. /** @hidden */ private _minX: number;
  19184. /** @hidden */ private _maxX: number;
  19185. /** @hidden */ private _minZ: number;
  19186. /** @hidden */ private _maxZ: number;
  19187. constructor(name: string, scene: Scene);
  19188. /**
  19189. * "GroundMesh"
  19190. * @returns "GroundMesh"
  19191. */
  19192. getClassName(): string;
  19193. /**
  19194. * The minimum of x and y subdivisions
  19195. */
  19196. readonly subdivisions: number;
  19197. /**
  19198. * X subdivisions
  19199. */
  19200. readonly subdivisionsX: number;
  19201. /**
  19202. * Y subdivisions
  19203. */
  19204. readonly subdivisionsY: number;
  19205. /**
  19206. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19207. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19208. * @param chunksCount the number of subdivisions for x and y
  19209. * @param octreeBlocksSize (Default: 32)
  19210. */
  19211. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19212. /**
  19213. * Returns a height (y) value in the Worl system :
  19214. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19215. * @param x x coordinate
  19216. * @param z z coordinate
  19217. * @returns the ground y position if (x, z) are outside the ground surface.
  19218. */
  19219. getHeightAtCoordinates(x: number, z: number): number;
  19220. /**
  19221. * Returns a normalized vector (Vector3) orthogonal to the ground
  19222. * at the ground coordinates (x, z) expressed in the World system.
  19223. * @param x x coordinate
  19224. * @param z z coordinate
  19225. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19226. */
  19227. getNormalAtCoordinates(x: number, z: number): Vector3;
  19228. /**
  19229. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19230. * at the ground coordinates (x, z) expressed in the World system.
  19231. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19232. * @param x x coordinate
  19233. * @param z z coordinate
  19234. * @param ref vector to store the result
  19235. * @returns the GroundMesh.
  19236. */
  19237. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19238. /**
  19239. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19240. * if the ground has been updated.
  19241. * This can be used in the render loop.
  19242. * @returns the GroundMesh.
  19243. */
  19244. updateCoordinateHeights(): GroundMesh;
  19245. private _getFacetAt;
  19246. private _initHeightQuads;
  19247. private _computeHeightQuads;
  19248. /**
  19249. * Serializes this ground mesh
  19250. * @param serializationObject object to write serialization to
  19251. */
  19252. serialize(serializationObject: any): void;
  19253. /**
  19254. * Parses a serialized ground mesh
  19255. * @param parsedMesh the serialized mesh
  19256. * @param scene the scene to create the ground mesh in
  19257. * @returns the created ground mesh
  19258. */
  19259. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19260. }
  19261. }
  19262. declare module BABYLON {
  19263. /**
  19264. * Interface for Physics-Joint data
  19265. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19266. */
  19267. export interface PhysicsJointData {
  19268. /**
  19269. * The main pivot of the joint
  19270. */
  19271. mainPivot?: Vector3;
  19272. /**
  19273. * The connected pivot of the joint
  19274. */
  19275. connectedPivot?: Vector3;
  19276. /**
  19277. * The main axis of the joint
  19278. */
  19279. mainAxis?: Vector3;
  19280. /**
  19281. * The connected axis of the joint
  19282. */
  19283. connectedAxis?: Vector3;
  19284. /**
  19285. * The collision of the joint
  19286. */
  19287. collision?: boolean;
  19288. /**
  19289. * Native Oimo/Cannon/Energy data
  19290. */
  19291. nativeParams?: any;
  19292. }
  19293. /**
  19294. * This is a holder class for the physics joint created by the physics plugin
  19295. * It holds a set of functions to control the underlying joint
  19296. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19297. */
  19298. export class PhysicsJoint {
  19299. /**
  19300. * The type of the physics joint
  19301. */
  19302. type: number;
  19303. /**
  19304. * The data for the physics joint
  19305. */
  19306. jointData: PhysicsJointData;
  19307. private _physicsJoint;
  19308. protected _physicsPlugin: IPhysicsEnginePlugin;
  19309. /**
  19310. * Initializes the physics joint
  19311. * @param type The type of the physics joint
  19312. * @param jointData The data for the physics joint
  19313. */
  19314. constructor(
  19315. /**
  19316. * The type of the physics joint
  19317. */
  19318. type: number,
  19319. /**
  19320. * The data for the physics joint
  19321. */
  19322. jointData: PhysicsJointData);
  19323. /**
  19324. * Gets the physics joint
  19325. */
  19326. /**
  19327. * Sets the physics joint
  19328. */
  19329. physicsJoint: any;
  19330. /**
  19331. * Sets the physics plugin
  19332. */
  19333. physicsPlugin: IPhysicsEnginePlugin;
  19334. /**
  19335. * Execute a function that is physics-plugin specific.
  19336. * @param {Function} func the function that will be executed.
  19337. * It accepts two parameters: the physics world and the physics joint
  19338. */
  19339. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  19340. /**
  19341. * Distance-Joint type
  19342. */
  19343. static DistanceJoint: number;
  19344. /**
  19345. * Hinge-Joint type
  19346. */
  19347. static HingeJoint: number;
  19348. /**
  19349. * Ball-and-Socket joint type
  19350. */
  19351. static BallAndSocketJoint: number;
  19352. /**
  19353. * Wheel-Joint type
  19354. */
  19355. static WheelJoint: number;
  19356. /**
  19357. * Slider-Joint type
  19358. */
  19359. static SliderJoint: number;
  19360. /**
  19361. * Prismatic-Joint type
  19362. */
  19363. static PrismaticJoint: number;
  19364. /**
  19365. * Universal-Joint type
  19366. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  19367. */
  19368. static UniversalJoint: number;
  19369. /**
  19370. * Hinge-Joint 2 type
  19371. */
  19372. static Hinge2Joint: number;
  19373. /**
  19374. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  19375. */
  19376. static PointToPointJoint: number;
  19377. /**
  19378. * Spring-Joint type
  19379. */
  19380. static SpringJoint: number;
  19381. /**
  19382. * Lock-Joint type
  19383. */
  19384. static LockJoint: number;
  19385. }
  19386. /**
  19387. * A class representing a physics distance joint
  19388. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19389. */
  19390. export class DistanceJoint extends PhysicsJoint {
  19391. /**
  19392. *
  19393. * @param jointData The data for the Distance-Joint
  19394. */
  19395. constructor(jointData: DistanceJointData);
  19396. /**
  19397. * Update the predefined distance.
  19398. * @param maxDistance The maximum preferred distance
  19399. * @param minDistance The minimum preferred distance
  19400. */
  19401. updateDistance(maxDistance: number, minDistance?: number): void;
  19402. }
  19403. /**
  19404. * Represents a Motor-Enabled Joint
  19405. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19406. */
  19407. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  19408. /**
  19409. * Initializes the Motor-Enabled Joint
  19410. * @param type The type of the joint
  19411. * @param jointData The physica joint data for the joint
  19412. */
  19413. constructor(type: number, jointData: PhysicsJointData);
  19414. /**
  19415. * Set the motor values.
  19416. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19417. * @param force the force to apply
  19418. * @param maxForce max force for this motor.
  19419. */
  19420. setMotor(force?: number, maxForce?: number): void;
  19421. /**
  19422. * Set the motor's limits.
  19423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19424. * @param upperLimit The upper limit of the motor
  19425. * @param lowerLimit The lower limit of the motor
  19426. */
  19427. setLimit(upperLimit: number, lowerLimit?: number): void;
  19428. }
  19429. /**
  19430. * This class represents a single physics Hinge-Joint
  19431. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19432. */
  19433. export class HingeJoint extends MotorEnabledJoint {
  19434. /**
  19435. * Initializes the Hinge-Joint
  19436. * @param jointData The joint data for the Hinge-Joint
  19437. */
  19438. constructor(jointData: PhysicsJointData);
  19439. /**
  19440. * Set the motor values.
  19441. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19442. * @param {number} force the force to apply
  19443. * @param {number} maxForce max force for this motor.
  19444. */
  19445. setMotor(force?: number, maxForce?: number): void;
  19446. /**
  19447. * Set the motor's limits.
  19448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19449. * @param upperLimit The upper limit of the motor
  19450. * @param lowerLimit The lower limit of the motor
  19451. */
  19452. setLimit(upperLimit: number, lowerLimit?: number): void;
  19453. }
  19454. /**
  19455. * This class represents a dual hinge physics joint (same as wheel joint)
  19456. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19457. */
  19458. export class Hinge2Joint extends MotorEnabledJoint {
  19459. /**
  19460. * Initializes the Hinge2-Joint
  19461. * @param jointData The joint data for the Hinge2-Joint
  19462. */
  19463. constructor(jointData: PhysicsJointData);
  19464. /**
  19465. * Set the motor values.
  19466. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19467. * @param {number} targetSpeed the speed the motor is to reach
  19468. * @param {number} maxForce max force for this motor.
  19469. * @param {motorIndex} the motor's index, 0 or 1.
  19470. */
  19471. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  19472. /**
  19473. * Set the motor limits.
  19474. * Attention, this function is plugin specific. Engines won't react 100% the same.
  19475. * @param {number} upperLimit the upper limit
  19476. * @param {number} lowerLimit lower limit
  19477. * @param {motorIndex} the motor's index, 0 or 1.
  19478. */
  19479. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19480. }
  19481. /**
  19482. * Interface for a motor enabled joint
  19483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19484. */
  19485. export interface IMotorEnabledJoint {
  19486. /**
  19487. * Physics joint
  19488. */
  19489. physicsJoint: any;
  19490. /**
  19491. * Sets the motor of the motor-enabled joint
  19492. * @param force The force of the motor
  19493. * @param maxForce The maximum force of the motor
  19494. * @param motorIndex The index of the motor
  19495. */
  19496. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  19497. /**
  19498. * Sets the limit of the motor
  19499. * @param upperLimit The upper limit of the motor
  19500. * @param lowerLimit The lower limit of the motor
  19501. * @param motorIndex The index of the motor
  19502. */
  19503. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19504. }
  19505. /**
  19506. * Joint data for a Distance-Joint
  19507. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19508. */
  19509. export interface DistanceJointData extends PhysicsJointData {
  19510. /**
  19511. * Max distance the 2 joint objects can be apart
  19512. */
  19513. maxDistance: number;
  19514. }
  19515. /**
  19516. * Joint data from a spring joint
  19517. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19518. */
  19519. export interface SpringJointData extends PhysicsJointData {
  19520. /**
  19521. * Length of the spring
  19522. */
  19523. length: number;
  19524. /**
  19525. * Stiffness of the spring
  19526. */
  19527. stiffness: number;
  19528. /**
  19529. * Damping of the spring
  19530. */
  19531. damping: number;
  19532. /** this callback will be called when applying the force to the impostors. */
  19533. forceApplicationCallback: () => void;
  19534. }
  19535. }
  19536. declare module BABYLON {
  19537. /**
  19538. * Holds the data for the raycast result
  19539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19540. */
  19541. export class PhysicsRaycastResult {
  19542. private _hasHit;
  19543. private _hitDistance;
  19544. private _hitNormalWorld;
  19545. private _hitPointWorld;
  19546. private _rayFromWorld;
  19547. private _rayToWorld;
  19548. /**
  19549. * Gets if there was a hit
  19550. */
  19551. readonly hasHit: boolean;
  19552. /**
  19553. * Gets the distance from the hit
  19554. */
  19555. readonly hitDistance: number;
  19556. /**
  19557. * Gets the hit normal/direction in the world
  19558. */
  19559. readonly hitNormalWorld: Vector3;
  19560. /**
  19561. * Gets the hit point in the world
  19562. */
  19563. readonly hitPointWorld: Vector3;
  19564. /**
  19565. * Gets the ray "start point" of the ray in the world
  19566. */
  19567. readonly rayFromWorld: Vector3;
  19568. /**
  19569. * Gets the ray "end point" of the ray in the world
  19570. */
  19571. readonly rayToWorld: Vector3;
  19572. /**
  19573. * Sets the hit data (normal & point in world space)
  19574. * @param hitNormalWorld defines the normal in world space
  19575. * @param hitPointWorld defines the point in world space
  19576. */
  19577. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  19578. /**
  19579. * Sets the distance from the start point to the hit point
  19580. * @param distance
  19581. */
  19582. setHitDistance(distance: number): void;
  19583. /**
  19584. * Calculates the distance manually
  19585. */
  19586. calculateHitDistance(): void;
  19587. /**
  19588. * Resets all the values to default
  19589. * @param from The from point on world space
  19590. * @param to The to point on world space
  19591. */
  19592. reset(from?: Vector3, to?: Vector3): void;
  19593. }
  19594. /**
  19595. * Interface for the size containing width and height
  19596. */
  19597. interface IXYZ {
  19598. /**
  19599. * X
  19600. */
  19601. x: number;
  19602. /**
  19603. * Y
  19604. */
  19605. y: number;
  19606. /**
  19607. * Z
  19608. */
  19609. z: number;
  19610. }
  19611. }
  19612. declare module BABYLON {
  19613. /**
  19614. * Interface used to describe a physics joint
  19615. */
  19616. export interface PhysicsImpostorJoint {
  19617. /** Defines the main impostor to which the joint is linked */
  19618. mainImpostor: PhysicsImpostor;
  19619. /** Defines the impostor that is connected to the main impostor using this joint */
  19620. connectedImpostor: PhysicsImpostor;
  19621. /** Defines the joint itself */
  19622. joint: PhysicsJoint;
  19623. }
  19624. /** @hidden */
  19625. export interface IPhysicsEnginePlugin {
  19626. world: any;
  19627. name: string;
  19628. setGravity(gravity: Vector3): void;
  19629. setTimeStep(timeStep: number): void;
  19630. getTimeStep(): number;
  19631. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  19632. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19633. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  19634. generatePhysicsBody(impostor: PhysicsImpostor): void;
  19635. removePhysicsBody(impostor: PhysicsImpostor): void;
  19636. generateJoint(joint: PhysicsImpostorJoint): void;
  19637. removeJoint(joint: PhysicsImpostorJoint): void;
  19638. isSupported(): boolean;
  19639. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  19640. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  19641. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19642. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  19643. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19644. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  19645. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  19646. getBodyMass(impostor: PhysicsImpostor): number;
  19647. getBodyFriction(impostor: PhysicsImpostor): number;
  19648. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  19649. getBodyRestitution(impostor: PhysicsImpostor): number;
  19650. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  19651. getBodyPressure?(impostor: PhysicsImpostor): number;
  19652. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  19653. getBodyStiffness?(impostor: PhysicsImpostor): number;
  19654. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  19655. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  19656. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  19657. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  19658. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  19659. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19660. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  19661. sleepBody(impostor: PhysicsImpostor): void;
  19662. wakeUpBody(impostor: PhysicsImpostor): void;
  19663. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19664. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  19665. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  19666. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  19667. getRadius(impostor: PhysicsImpostor): number;
  19668. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  19669. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  19670. dispose(): void;
  19671. }
  19672. /**
  19673. * Interface used to define a physics engine
  19674. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  19675. */
  19676. export interface IPhysicsEngine {
  19677. /**
  19678. * Gets the gravity vector used by the simulation
  19679. */
  19680. gravity: Vector3;
  19681. /**
  19682. * Sets the gravity vector used by the simulation
  19683. * @param gravity defines the gravity vector to use
  19684. */
  19685. setGravity(gravity: Vector3): void;
  19686. /**
  19687. * Set the time step of the physics engine.
  19688. * Default is 1/60.
  19689. * To slow it down, enter 1/600 for example.
  19690. * To speed it up, 1/30
  19691. * @param newTimeStep the new timestep to apply to this world.
  19692. */
  19693. setTimeStep(newTimeStep: number): void;
  19694. /**
  19695. * Get the time step of the physics engine.
  19696. * @returns the current time step
  19697. */
  19698. getTimeStep(): number;
  19699. /**
  19700. * Release all resources
  19701. */
  19702. dispose(): void;
  19703. /**
  19704. * Gets the name of the current physics plugin
  19705. * @returns the name of the plugin
  19706. */
  19707. getPhysicsPluginName(): string;
  19708. /**
  19709. * Adding a new impostor for the impostor tracking.
  19710. * This will be done by the impostor itself.
  19711. * @param impostor the impostor to add
  19712. */
  19713. addImpostor(impostor: PhysicsImpostor): void;
  19714. /**
  19715. * Remove an impostor from the engine.
  19716. * This impostor and its mesh will not longer be updated by the physics engine.
  19717. * @param impostor the impostor to remove
  19718. */
  19719. removeImpostor(impostor: PhysicsImpostor): void;
  19720. /**
  19721. * Add a joint to the physics engine
  19722. * @param mainImpostor defines the main impostor to which the joint is added.
  19723. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  19724. * @param joint defines the joint that will connect both impostors.
  19725. */
  19726. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19727. /**
  19728. * Removes a joint from the simulation
  19729. * @param mainImpostor defines the impostor used with the joint
  19730. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  19731. * @param joint defines the joint to remove
  19732. */
  19733. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  19734. /**
  19735. * Gets the current plugin used to run the simulation
  19736. * @returns current plugin
  19737. */
  19738. getPhysicsPlugin(): IPhysicsEnginePlugin;
  19739. /**
  19740. * Gets the list of physic impostors
  19741. * @returns an array of PhysicsImpostor
  19742. */
  19743. getImpostors(): Array<PhysicsImpostor>;
  19744. /**
  19745. * Gets the impostor for a physics enabled object
  19746. * @param object defines the object impersonated by the impostor
  19747. * @returns the PhysicsImpostor or null if not found
  19748. */
  19749. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  19750. /**
  19751. * Gets the impostor for a physics body object
  19752. * @param body defines physics body used by the impostor
  19753. * @returns the PhysicsImpostor or null if not found
  19754. */
  19755. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  19756. /**
  19757. * Does a raycast in the physics world
  19758. * @param from when should the ray start?
  19759. * @param to when should the ray end?
  19760. * @returns PhysicsRaycastResult
  19761. */
  19762. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  19763. /**
  19764. * Called by the scene. No need to call it.
  19765. * @param delta defines the timespam between frames
  19766. */ private _step(delta: number): void;
  19767. }
  19768. }
  19769. declare module BABYLON {
  19770. /**
  19771. * The interface for the physics imposter parameters
  19772. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19773. */
  19774. export interface PhysicsImpostorParameters {
  19775. /**
  19776. * The mass of the physics imposter
  19777. */
  19778. mass: number;
  19779. /**
  19780. * The friction of the physics imposter
  19781. */
  19782. friction?: number;
  19783. /**
  19784. * The coefficient of restitution of the physics imposter
  19785. */
  19786. restitution?: number;
  19787. /**
  19788. * The native options of the physics imposter
  19789. */
  19790. nativeOptions?: any;
  19791. /**
  19792. * Specifies if the parent should be ignored
  19793. */
  19794. ignoreParent?: boolean;
  19795. /**
  19796. * Specifies if bi-directional transformations should be disabled
  19797. */
  19798. disableBidirectionalTransformation?: boolean;
  19799. /**
  19800. * The pressure inside the physics imposter, soft object only
  19801. */
  19802. pressure?: number;
  19803. /**
  19804. * The stiffness the physics imposter, soft object only
  19805. */
  19806. stiffness?: number;
  19807. /**
  19808. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  19809. */
  19810. velocityIterations?: number;
  19811. /**
  19812. * The number of iterations used in maintaining consistent vertex positions, soft object only
  19813. */
  19814. positionIterations?: number;
  19815. /**
  19816. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  19817. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  19818. * Add to fix multiple points
  19819. */
  19820. fixedPoints?: number;
  19821. /**
  19822. * The collision margin around a soft object
  19823. */
  19824. margin?: number;
  19825. /**
  19826. * The collision margin around a soft object
  19827. */
  19828. damping?: number;
  19829. /**
  19830. * The path for a rope based on an extrusion
  19831. */
  19832. path?: any;
  19833. /**
  19834. * The shape of an extrusion used for a rope based on an extrusion
  19835. */
  19836. shape?: any;
  19837. }
  19838. /**
  19839. * Interface for a physics-enabled object
  19840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19841. */
  19842. export interface IPhysicsEnabledObject {
  19843. /**
  19844. * The position of the physics-enabled object
  19845. */
  19846. position: Vector3;
  19847. /**
  19848. * The rotation of the physics-enabled object
  19849. */
  19850. rotationQuaternion: Nullable<Quaternion>;
  19851. /**
  19852. * The scale of the physics-enabled object
  19853. */
  19854. scaling: Vector3;
  19855. /**
  19856. * The rotation of the physics-enabled object
  19857. */
  19858. rotation?: Vector3;
  19859. /**
  19860. * The parent of the physics-enabled object
  19861. */
  19862. parent?: any;
  19863. /**
  19864. * The bounding info of the physics-enabled object
  19865. * @returns The bounding info of the physics-enabled object
  19866. */
  19867. getBoundingInfo(): BoundingInfo;
  19868. /**
  19869. * Computes the world matrix
  19870. * @param force Specifies if the world matrix should be computed by force
  19871. * @returns A world matrix
  19872. */
  19873. computeWorldMatrix(force: boolean): Matrix;
  19874. /**
  19875. * Gets the world matrix
  19876. * @returns A world matrix
  19877. */
  19878. getWorldMatrix?(): Matrix;
  19879. /**
  19880. * Gets the child meshes
  19881. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  19882. * @returns An array of abstract meshes
  19883. */
  19884. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  19885. /**
  19886. * Gets the vertex data
  19887. * @param kind The type of vertex data
  19888. * @returns A nullable array of numbers, or a float32 array
  19889. */
  19890. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  19891. /**
  19892. * Gets the indices from the mesh
  19893. * @returns A nullable array of index arrays
  19894. */
  19895. getIndices?(): Nullable<IndicesArray>;
  19896. /**
  19897. * Gets the scene from the mesh
  19898. * @returns the indices array or null
  19899. */
  19900. getScene?(): Scene;
  19901. /**
  19902. * Gets the absolute position from the mesh
  19903. * @returns the absolute position
  19904. */
  19905. getAbsolutePosition(): Vector3;
  19906. /**
  19907. * Gets the absolute pivot point from the mesh
  19908. * @returns the absolute pivot point
  19909. */
  19910. getAbsolutePivotPoint(): Vector3;
  19911. /**
  19912. * Rotates the mesh
  19913. * @param axis The axis of rotation
  19914. * @param amount The amount of rotation
  19915. * @param space The space of the rotation
  19916. * @returns The rotation transform node
  19917. */
  19918. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  19919. /**
  19920. * Translates the mesh
  19921. * @param axis The axis of translation
  19922. * @param distance The distance of translation
  19923. * @param space The space of the translation
  19924. * @returns The transform node
  19925. */
  19926. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  19927. /**
  19928. * Sets the absolute position of the mesh
  19929. * @param absolutePosition The absolute position of the mesh
  19930. * @returns The transform node
  19931. */
  19932. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  19933. /**
  19934. * Gets the class name of the mesh
  19935. * @returns The class name
  19936. */
  19937. getClassName(): string;
  19938. }
  19939. /**
  19940. * Represents a physics imposter
  19941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19942. */
  19943. export class PhysicsImpostor {
  19944. /**
  19945. * The physics-enabled object used as the physics imposter
  19946. */
  19947. object: IPhysicsEnabledObject;
  19948. /**
  19949. * The type of the physics imposter
  19950. */
  19951. type: number;
  19952. private _options;
  19953. private _scene?;
  19954. /**
  19955. * The default object size of the imposter
  19956. */
  19957. static DEFAULT_OBJECT_SIZE: Vector3;
  19958. /**
  19959. * The identity quaternion of the imposter
  19960. */
  19961. static IDENTITY_QUATERNION: Quaternion;
  19962. /** @hidden */ private _pluginData: any;
  19963. private _physicsEngine;
  19964. private _physicsBody;
  19965. private _bodyUpdateRequired;
  19966. private _onBeforePhysicsStepCallbacks;
  19967. private _onAfterPhysicsStepCallbacks;
  19968. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  19969. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  19970. otherImpostors: Array<PhysicsImpostor>;
  19971. }>;
  19972. private _deltaPosition;
  19973. private _deltaRotation;
  19974. private _deltaRotationConjugated;
  19975. /** hidden */ private _isFromLine: boolean;
  19976. private _parent;
  19977. private _isDisposed;
  19978. private static _tmpVecs;
  19979. private static _tmpQuat;
  19980. /**
  19981. * Specifies if the physics imposter is disposed
  19982. */
  19983. readonly isDisposed: boolean;
  19984. /**
  19985. * Gets the mass of the physics imposter
  19986. */
  19987. mass: number;
  19988. /**
  19989. * Gets the coefficient of friction
  19990. */
  19991. /**
  19992. * Sets the coefficient of friction
  19993. */
  19994. friction: number;
  19995. /**
  19996. * Gets the coefficient of restitution
  19997. */
  19998. /**
  19999. * Sets the coefficient of restitution
  20000. */
  20001. restitution: number;
  20002. /**
  20003. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20004. */
  20005. /**
  20006. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20007. */
  20008. pressure: number;
  20009. /**
  20010. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20011. */
  20012. /**
  20013. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20014. */
  20015. stiffness: number;
  20016. /**
  20017. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20018. */
  20019. /**
  20020. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20021. */
  20022. velocityIterations: number;
  20023. /**
  20024. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20025. */
  20026. /**
  20027. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20028. */
  20029. positionIterations: number;
  20030. /**
  20031. * The unique id of the physics imposter
  20032. * set by the physics engine when adding this impostor to the array
  20033. */
  20034. uniqueId: number;
  20035. /**
  20036. * @hidden
  20037. */
  20038. soft: boolean;
  20039. /**
  20040. * @hidden
  20041. */
  20042. segments: number;
  20043. private _joints;
  20044. /**
  20045. * Initializes the physics imposter
  20046. * @param object The physics-enabled object used as the physics imposter
  20047. * @param type The type of the physics imposter
  20048. * @param _options The options for the physics imposter
  20049. * @param _scene The Babylon scene
  20050. */
  20051. constructor(
  20052. /**
  20053. * The physics-enabled object used as the physics imposter
  20054. */
  20055. object: IPhysicsEnabledObject,
  20056. /**
  20057. * The type of the physics imposter
  20058. */
  20059. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20060. /**
  20061. * This function will completly initialize this impostor.
  20062. * It will create a new body - but only if this mesh has no parent.
  20063. * If it has, this impostor will not be used other than to define the impostor
  20064. * of the child mesh.
  20065. * @hidden
  20066. */ private _init(): void;
  20067. private _getPhysicsParent;
  20068. /**
  20069. * Should a new body be generated.
  20070. * @returns boolean specifying if body initialization is required
  20071. */
  20072. isBodyInitRequired(): boolean;
  20073. /**
  20074. * Sets the updated scaling
  20075. * @param updated Specifies if the scaling is updated
  20076. */
  20077. setScalingUpdated(): void;
  20078. /**
  20079. * Force a regeneration of this or the parent's impostor's body.
  20080. * Use under cautious - This will remove all joints already implemented.
  20081. */
  20082. forceUpdate(): void;
  20083. /**
  20084. * Gets the body that holds this impostor. Either its own, or its parent.
  20085. */
  20086. /**
  20087. * Set the physics body. Used mainly by the physics engine/plugin
  20088. */
  20089. physicsBody: any;
  20090. /**
  20091. * Get the parent of the physics imposter
  20092. * @returns Physics imposter or null
  20093. */
  20094. /**
  20095. * Sets the parent of the physics imposter
  20096. */
  20097. parent: Nullable<PhysicsImpostor>;
  20098. /**
  20099. * Resets the update flags
  20100. */
  20101. resetUpdateFlags(): void;
  20102. /**
  20103. * Gets the object extend size
  20104. * @returns the object extend size
  20105. */
  20106. getObjectExtendSize(): Vector3;
  20107. /**
  20108. * Gets the object center
  20109. * @returns The object center
  20110. */
  20111. getObjectCenter(): Vector3;
  20112. /**
  20113. * Get a specific parametes from the options parameter
  20114. * @param paramName The object parameter name
  20115. * @returns The object parameter
  20116. */
  20117. getParam(paramName: string): any;
  20118. /**
  20119. * Sets a specific parameter in the options given to the physics plugin
  20120. * @param paramName The parameter name
  20121. * @param value The value of the parameter
  20122. */
  20123. setParam(paramName: string, value: number): void;
  20124. /**
  20125. * Specifically change the body's mass option. Won't recreate the physics body object
  20126. * @param mass The mass of the physics imposter
  20127. */
  20128. setMass(mass: number): void;
  20129. /**
  20130. * Gets the linear velocity
  20131. * @returns linear velocity or null
  20132. */
  20133. getLinearVelocity(): Nullable<Vector3>;
  20134. /**
  20135. * Sets the linear velocity
  20136. * @param velocity linear velocity or null
  20137. */
  20138. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20139. /**
  20140. * Gets the angular velocity
  20141. * @returns angular velocity or null
  20142. */
  20143. getAngularVelocity(): Nullable<Vector3>;
  20144. /**
  20145. * Sets the angular velocity
  20146. * @param velocity The velocity or null
  20147. */
  20148. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20149. /**
  20150. * Execute a function with the physics plugin native code
  20151. * Provide a function the will have two variables - the world object and the physics body object
  20152. * @param func The function to execute with the physics plugin native code
  20153. */
  20154. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20155. /**
  20156. * Register a function that will be executed before the physics world is stepping forward
  20157. * @param func The function to execute before the physics world is stepped forward
  20158. */
  20159. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20160. /**
  20161. * Unregister a function that will be executed before the physics world is stepping forward
  20162. * @param func The function to execute before the physics world is stepped forward
  20163. */
  20164. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20165. /**
  20166. * Register a function that will be executed after the physics step
  20167. * @param func The function to execute after physics step
  20168. */
  20169. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20170. /**
  20171. * Unregisters a function that will be executed after the physics step
  20172. * @param func The function to execute after physics step
  20173. */
  20174. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20175. /**
  20176. * register a function that will be executed when this impostor collides against a different body
  20177. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20178. * @param func Callback that is executed on collision
  20179. */
  20180. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20181. /**
  20182. * Unregisters the physics imposter on contact
  20183. * @param collideAgainst The physics object to collide against
  20184. * @param func Callback to execute on collision
  20185. */
  20186. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20187. private _tmpQuat;
  20188. private _tmpQuat2;
  20189. /**
  20190. * Get the parent rotation
  20191. * @returns The parent rotation
  20192. */
  20193. getParentsRotation(): Quaternion;
  20194. /**
  20195. * this function is executed by the physics engine.
  20196. */
  20197. beforeStep: () => void;
  20198. /**
  20199. * this function is executed by the physics engine
  20200. */
  20201. afterStep: () => void;
  20202. /**
  20203. * Legacy collision detection event support
  20204. */
  20205. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20206. /**
  20207. * event and body object due to cannon's event-based architecture.
  20208. */
  20209. onCollide: (e: {
  20210. body: any;
  20211. }) => void;
  20212. /**
  20213. * Apply a force
  20214. * @param force The force to apply
  20215. * @param contactPoint The contact point for the force
  20216. * @returns The physics imposter
  20217. */
  20218. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20219. /**
  20220. * Apply an impulse
  20221. * @param force The impulse force
  20222. * @param contactPoint The contact point for the impulse force
  20223. * @returns The physics imposter
  20224. */
  20225. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20226. /**
  20227. * A help function to create a joint
  20228. * @param otherImpostor A physics imposter used to create a joint
  20229. * @param jointType The type of joint
  20230. * @param jointData The data for the joint
  20231. * @returns The physics imposter
  20232. */
  20233. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20234. /**
  20235. * Add a joint to this impostor with a different impostor
  20236. * @param otherImpostor A physics imposter used to add a joint
  20237. * @param joint The joint to add
  20238. * @returns The physics imposter
  20239. */
  20240. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20241. /**
  20242. * Add an anchor to a cloth impostor
  20243. * @param otherImpostor rigid impostor to anchor to
  20244. * @param width ratio across width from 0 to 1
  20245. * @param height ratio up height from 0 to 1
  20246. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20247. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20248. * @returns impostor the soft imposter
  20249. */
  20250. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20251. /**
  20252. * Add a hook to a rope impostor
  20253. * @param otherImpostor rigid impostor to anchor to
  20254. * @param length ratio across rope from 0 to 1
  20255. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20256. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20257. * @returns impostor the rope imposter
  20258. */
  20259. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20260. /**
  20261. * Will keep this body still, in a sleep mode.
  20262. * @returns the physics imposter
  20263. */
  20264. sleep(): PhysicsImpostor;
  20265. /**
  20266. * Wake the body up.
  20267. * @returns The physics imposter
  20268. */
  20269. wakeUp(): PhysicsImpostor;
  20270. /**
  20271. * Clones the physics imposter
  20272. * @param newObject The physics imposter clones to this physics-enabled object
  20273. * @returns A nullable physics imposter
  20274. */
  20275. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20276. /**
  20277. * Disposes the physics imposter
  20278. */
  20279. dispose(): void;
  20280. /**
  20281. * Sets the delta position
  20282. * @param position The delta position amount
  20283. */
  20284. setDeltaPosition(position: Vector3): void;
  20285. /**
  20286. * Sets the delta rotation
  20287. * @param rotation The delta rotation amount
  20288. */
  20289. setDeltaRotation(rotation: Quaternion): void;
  20290. /**
  20291. * Gets the box size of the physics imposter and stores the result in the input parameter
  20292. * @param result Stores the box size
  20293. * @returns The physics imposter
  20294. */
  20295. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20296. /**
  20297. * Gets the radius of the physics imposter
  20298. * @returns Radius of the physics imposter
  20299. */
  20300. getRadius(): number;
  20301. /**
  20302. * Sync a bone with this impostor
  20303. * @param bone The bone to sync to the impostor.
  20304. * @param boneMesh The mesh that the bone is influencing.
  20305. * @param jointPivot The pivot of the joint / bone in local space.
  20306. * @param distToJoint Optional distance from the impostor to the joint.
  20307. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20308. */
  20309. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  20310. /**
  20311. * Sync impostor to a bone
  20312. * @param bone The bone that the impostor will be synced to.
  20313. * @param boneMesh The mesh that the bone is influencing.
  20314. * @param jointPivot The pivot of the joint / bone in local space.
  20315. * @param distToJoint Optional distance from the impostor to the joint.
  20316. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  20317. * @param boneAxis Optional vector3 axis the bone is aligned with
  20318. */
  20319. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  20320. /**
  20321. * No-Imposter type
  20322. */
  20323. static NoImpostor: number;
  20324. /**
  20325. * Sphere-Imposter type
  20326. */
  20327. static SphereImpostor: number;
  20328. /**
  20329. * Box-Imposter type
  20330. */
  20331. static BoxImpostor: number;
  20332. /**
  20333. * Plane-Imposter type
  20334. */
  20335. static PlaneImpostor: number;
  20336. /**
  20337. * Mesh-imposter type
  20338. */
  20339. static MeshImpostor: number;
  20340. /**
  20341. * Cylinder-Imposter type
  20342. */
  20343. static CylinderImpostor: number;
  20344. /**
  20345. * Particle-Imposter type
  20346. */
  20347. static ParticleImpostor: number;
  20348. /**
  20349. * Heightmap-Imposter type
  20350. */
  20351. static HeightmapImpostor: number;
  20352. /**
  20353. * ConvexHull-Impostor type (Ammo.js plugin only)
  20354. */
  20355. static ConvexHullImpostor: number;
  20356. /**
  20357. * Rope-Imposter type
  20358. */
  20359. static RopeImpostor: number;
  20360. /**
  20361. * Cloth-Imposter type
  20362. */
  20363. static ClothImpostor: number;
  20364. /**
  20365. * Softbody-Imposter type
  20366. */
  20367. static SoftbodyImpostor: number;
  20368. }
  20369. }
  20370. declare module BABYLON {
  20371. /**
  20372. * @hidden
  20373. **/
  20374. export class _CreationDataStorage {
  20375. closePath?: boolean;
  20376. closeArray?: boolean;
  20377. idx: number[];
  20378. dashSize: number;
  20379. gapSize: number;
  20380. path3D: Path3D;
  20381. pathArray: Vector3[][];
  20382. arc: number;
  20383. radius: number;
  20384. cap: number;
  20385. tessellation: number;
  20386. }
  20387. /**
  20388. * @hidden
  20389. **/ private class _InstanceDataStorage {
  20390. visibleInstances: any;
  20391. batchCache: _InstancesBatch;
  20392. instancesBufferSize: number;
  20393. instancesBuffer: Nullable<Buffer>;
  20394. instancesData: Float32Array;
  20395. overridenInstanceCount: number;
  20396. isFrozen: boolean;
  20397. previousBatch: _InstancesBatch;
  20398. hardwareInstancedRendering: boolean;
  20399. sideOrientation: number;
  20400. }
  20401. /**
  20402. * @hidden
  20403. **/
  20404. export class _InstancesBatch {
  20405. mustReturn: boolean;
  20406. visibleInstances: Nullable<InstancedMesh[]>[];
  20407. renderSelf: boolean[];
  20408. hardwareInstancedRendering: boolean[];
  20409. }
  20410. /**
  20411. * Class used to represent renderable models
  20412. */
  20413. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  20414. /**
  20415. * Mesh side orientation : usually the external or front surface
  20416. */
  20417. static readonly FRONTSIDE: number;
  20418. /**
  20419. * Mesh side orientation : usually the internal or back surface
  20420. */
  20421. static readonly BACKSIDE: number;
  20422. /**
  20423. * Mesh side orientation : both internal and external or front and back surfaces
  20424. */
  20425. static readonly DOUBLESIDE: number;
  20426. /**
  20427. * Mesh side orientation : by default, `FRONTSIDE`
  20428. */
  20429. static readonly DEFAULTSIDE: number;
  20430. /**
  20431. * Mesh cap setting : no cap
  20432. */
  20433. static readonly NO_CAP: number;
  20434. /**
  20435. * Mesh cap setting : one cap at the beginning of the mesh
  20436. */
  20437. static readonly CAP_START: number;
  20438. /**
  20439. * Mesh cap setting : one cap at the end of the mesh
  20440. */
  20441. static readonly CAP_END: number;
  20442. /**
  20443. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  20444. */
  20445. static readonly CAP_ALL: number;
  20446. /**
  20447. * Mesh pattern setting : no flip or rotate
  20448. */
  20449. static readonly NO_FLIP: number;
  20450. /**
  20451. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  20452. */
  20453. static readonly FLIP_TILE: number;
  20454. /**
  20455. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  20456. */
  20457. static readonly ROTATE_TILE: number;
  20458. /**
  20459. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  20460. */
  20461. static readonly FLIP_ROW: number;
  20462. /**
  20463. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  20464. */
  20465. static readonly ROTATE_ROW: number;
  20466. /**
  20467. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  20468. */
  20469. static readonly FLIP_N_ROTATE_TILE: number;
  20470. /**
  20471. * Mesh pattern setting : rotate pattern and rotate
  20472. */
  20473. static readonly FLIP_N_ROTATE_ROW: number;
  20474. /**
  20475. * Mesh tile positioning : part tiles same on left/right or top/bottom
  20476. */
  20477. static readonly CENTER: number;
  20478. /**
  20479. * Mesh tile positioning : part tiles on left
  20480. */
  20481. static readonly LEFT: number;
  20482. /**
  20483. * Mesh tile positioning : part tiles on right
  20484. */
  20485. static readonly RIGHT: number;
  20486. /**
  20487. * Mesh tile positioning : part tiles on top
  20488. */
  20489. static readonly TOP: number;
  20490. /**
  20491. * Mesh tile positioning : part tiles on bottom
  20492. */
  20493. static readonly BOTTOM: number;
  20494. /**
  20495. * Gets the default side orientation.
  20496. * @param orientation the orientation to value to attempt to get
  20497. * @returns the default orientation
  20498. * @hidden
  20499. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  20500. private _internalMeshDataInfo;
  20501. /**
  20502. * An event triggered before rendering the mesh
  20503. */
  20504. readonly onBeforeRenderObservable: Observable<Mesh>;
  20505. /**
  20506. * An event triggered before binding the mesh
  20507. */
  20508. readonly onBeforeBindObservable: Observable<Mesh>;
  20509. /**
  20510. * An event triggered after rendering the mesh
  20511. */
  20512. readonly onAfterRenderObservable: Observable<Mesh>;
  20513. /**
  20514. * An event triggered before drawing the mesh
  20515. */
  20516. readonly onBeforeDrawObservable: Observable<Mesh>;
  20517. private _onBeforeDrawObserver;
  20518. /**
  20519. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  20520. */
  20521. onBeforeDraw: () => void;
  20522. /**
  20523. * Gets the delay loading state of the mesh (when delay loading is turned on)
  20524. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  20525. */
  20526. delayLoadState: number;
  20527. /**
  20528. * Gets the list of instances created from this mesh
  20529. * it is not supposed to be modified manually.
  20530. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  20531. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  20532. */
  20533. instances: InstancedMesh[];
  20534. /**
  20535. * Gets the file containing delay loading data for this mesh
  20536. */
  20537. delayLoadingFile: string;
  20538. /** @hidden */ private _binaryInfo: any;
  20539. /**
  20540. * User defined function used to change how LOD level selection is done
  20541. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20542. */
  20543. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  20544. /**
  20545. * Gets or sets the morph target manager
  20546. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  20547. */
  20548. morphTargetManager: Nullable<MorphTargetManager>;
  20549. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  20550. /** @hidden */ private _geometry: Nullable<Geometry>;
  20551. /** @hidden */ private _delayInfo: Array<string>;
  20552. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  20553. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  20554. private _effectiveMaterial;
  20555. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  20556. /** @hidden */ private _originalBuilderSideOrientation: number;
  20557. /**
  20558. * Use this property to change the original side orientation defined at construction time
  20559. */
  20560. overrideMaterialSideOrientation: Nullable<number>;
  20561. /**
  20562. * Gets the source mesh (the one used to clone this one from)
  20563. */
  20564. readonly source: Nullable<Mesh>;
  20565. /**
  20566. * Gets or sets a boolean indicating that this mesh does not use index buffer
  20567. */
  20568. isUnIndexed: boolean;
  20569. /**
  20570. * @constructor
  20571. * @param name The value used by scene.getMeshByName() to do a lookup.
  20572. * @param scene The scene to add this mesh to.
  20573. * @param parent The parent of this mesh, if it has one
  20574. * @param source An optional Mesh from which geometry is shared, cloned.
  20575. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  20576. * When false, achieved by calling a clone(), also passing False.
  20577. * This will make creation of children, recursive.
  20578. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  20579. */
  20580. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  20581. /**
  20582. * Gets the class name
  20583. * @returns the string "Mesh".
  20584. */
  20585. getClassName(): string;
  20586. /** @hidden */ protected readonly _isMesh: boolean;
  20587. /**
  20588. * Returns a description of this mesh
  20589. * @param fullDetails define if full details about this mesh must be used
  20590. * @returns a descriptive string representing this mesh
  20591. */
  20592. toString(fullDetails?: boolean): string;
  20593. /** @hidden */ private _unBindEffect(): void;
  20594. /**
  20595. * Gets a boolean indicating if this mesh has LOD
  20596. */
  20597. readonly hasLODLevels: boolean;
  20598. /**
  20599. * Gets the list of MeshLODLevel associated with the current mesh
  20600. * @returns an array of MeshLODLevel
  20601. */
  20602. getLODLevels(): MeshLODLevel[];
  20603. private _sortLODLevels;
  20604. /**
  20605. * Add a mesh as LOD level triggered at the given distance.
  20606. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20607. * @param distance The distance from the center of the object to show this level
  20608. * @param mesh The mesh to be added as LOD level (can be null)
  20609. * @return This mesh (for chaining)
  20610. */
  20611. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  20612. /**
  20613. * Returns the LOD level mesh at the passed distance or null if not found.
  20614. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20615. * @param distance The distance from the center of the object to show this level
  20616. * @returns a Mesh or `null`
  20617. */
  20618. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  20619. /**
  20620. * Remove a mesh from the LOD array
  20621. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20622. * @param mesh defines the mesh to be removed
  20623. * @return This mesh (for chaining)
  20624. */
  20625. removeLODLevel(mesh: Mesh): Mesh;
  20626. /**
  20627. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  20628. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  20629. * @param camera defines the camera to use to compute distance
  20630. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  20631. * @return This mesh (for chaining)
  20632. */
  20633. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  20634. /**
  20635. * Gets the mesh internal Geometry object
  20636. */
  20637. readonly geometry: Nullable<Geometry>;
  20638. /**
  20639. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  20640. * @returns the total number of vertices
  20641. */
  20642. getTotalVertices(): number;
  20643. /**
  20644. * Returns the content of an associated vertex buffer
  20645. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20646. * - VertexBuffer.PositionKind
  20647. * - VertexBuffer.UVKind
  20648. * - VertexBuffer.UV2Kind
  20649. * - VertexBuffer.UV3Kind
  20650. * - VertexBuffer.UV4Kind
  20651. * - VertexBuffer.UV5Kind
  20652. * - VertexBuffer.UV6Kind
  20653. * - VertexBuffer.ColorKind
  20654. * - VertexBuffer.MatricesIndicesKind
  20655. * - VertexBuffer.MatricesIndicesExtraKind
  20656. * - VertexBuffer.MatricesWeightsKind
  20657. * - VertexBuffer.MatricesWeightsExtraKind
  20658. * @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
  20659. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  20660. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  20661. */
  20662. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20663. /**
  20664. * Returns the mesh VertexBuffer object from the requested `kind`
  20665. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20666. * - VertexBuffer.PositionKind
  20667. * - VertexBuffer.NormalKind
  20668. * - VertexBuffer.UVKind
  20669. * - VertexBuffer.UV2Kind
  20670. * - VertexBuffer.UV3Kind
  20671. * - VertexBuffer.UV4Kind
  20672. * - VertexBuffer.UV5Kind
  20673. * - VertexBuffer.UV6Kind
  20674. * - VertexBuffer.ColorKind
  20675. * - VertexBuffer.MatricesIndicesKind
  20676. * - VertexBuffer.MatricesIndicesExtraKind
  20677. * - VertexBuffer.MatricesWeightsKind
  20678. * - VertexBuffer.MatricesWeightsExtraKind
  20679. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  20680. */
  20681. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20682. /**
  20683. * Tests if a specific vertex buffer is associated with this mesh
  20684. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20685. * - VertexBuffer.PositionKind
  20686. * - VertexBuffer.NormalKind
  20687. * - VertexBuffer.UVKind
  20688. * - VertexBuffer.UV2Kind
  20689. * - VertexBuffer.UV3Kind
  20690. * - VertexBuffer.UV4Kind
  20691. * - VertexBuffer.UV5Kind
  20692. * - VertexBuffer.UV6Kind
  20693. * - VertexBuffer.ColorKind
  20694. * - VertexBuffer.MatricesIndicesKind
  20695. * - VertexBuffer.MatricesIndicesExtraKind
  20696. * - VertexBuffer.MatricesWeightsKind
  20697. * - VertexBuffer.MatricesWeightsExtraKind
  20698. * @returns a boolean
  20699. */
  20700. isVerticesDataPresent(kind: string): boolean;
  20701. /**
  20702. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  20703. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  20704. * - VertexBuffer.PositionKind
  20705. * - VertexBuffer.UVKind
  20706. * - VertexBuffer.UV2Kind
  20707. * - VertexBuffer.UV3Kind
  20708. * - VertexBuffer.UV4Kind
  20709. * - VertexBuffer.UV5Kind
  20710. * - VertexBuffer.UV6Kind
  20711. * - VertexBuffer.ColorKind
  20712. * - VertexBuffer.MatricesIndicesKind
  20713. * - VertexBuffer.MatricesIndicesExtraKind
  20714. * - VertexBuffer.MatricesWeightsKind
  20715. * - VertexBuffer.MatricesWeightsExtraKind
  20716. * @returns a boolean
  20717. */
  20718. isVertexBufferUpdatable(kind: string): boolean;
  20719. /**
  20720. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  20721. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  20722. * - VertexBuffer.PositionKind
  20723. * - VertexBuffer.NormalKind
  20724. * - VertexBuffer.UVKind
  20725. * - VertexBuffer.UV2Kind
  20726. * - VertexBuffer.UV3Kind
  20727. * - VertexBuffer.UV4Kind
  20728. * - VertexBuffer.UV5Kind
  20729. * - VertexBuffer.UV6Kind
  20730. * - VertexBuffer.ColorKind
  20731. * - VertexBuffer.MatricesIndicesKind
  20732. * - VertexBuffer.MatricesIndicesExtraKind
  20733. * - VertexBuffer.MatricesWeightsKind
  20734. * - VertexBuffer.MatricesWeightsExtraKind
  20735. * @returns an array of strings
  20736. */
  20737. getVerticesDataKinds(): string[];
  20738. /**
  20739. * Returns a positive integer : the total number of indices in this mesh geometry.
  20740. * @returns the numner of indices or zero if the mesh has no geometry.
  20741. */
  20742. getTotalIndices(): number;
  20743. /**
  20744. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20745. * @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.
  20746. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20747. * @returns the indices array or an empty array if the mesh has no geometry
  20748. */
  20749. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20750. readonly isBlocked: boolean;
  20751. /**
  20752. * Determine if the current mesh is ready to be rendered
  20753. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  20754. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  20755. * @returns true if all associated assets are ready (material, textures, shaders)
  20756. */
  20757. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  20758. /**
  20759. * 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.
  20760. */
  20761. readonly areNormalsFrozen: boolean;
  20762. /**
  20763. * 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.
  20764. * @returns the current mesh
  20765. */
  20766. freezeNormals(): Mesh;
  20767. /**
  20768. * 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
  20769. * @returns the current mesh
  20770. */
  20771. unfreezeNormals(): Mesh;
  20772. /**
  20773. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  20774. */
  20775. overridenInstanceCount: number;
  20776. /** @hidden */ private _preActivate(): Mesh;
  20777. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  20778. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  20779. /**
  20780. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  20781. * This means the mesh underlying bounding box and sphere are recomputed.
  20782. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  20783. * @returns the current mesh
  20784. */
  20785. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  20786. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  20787. /**
  20788. * This function will subdivide the mesh into multiple submeshes
  20789. * @param count defines the expected number of submeshes
  20790. */
  20791. subdivide(count: number): void;
  20792. /**
  20793. * Copy a FloatArray into a specific associated vertex buffer
  20794. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20795. * - VertexBuffer.PositionKind
  20796. * - VertexBuffer.UVKind
  20797. * - VertexBuffer.UV2Kind
  20798. * - VertexBuffer.UV3Kind
  20799. * - VertexBuffer.UV4Kind
  20800. * - VertexBuffer.UV5Kind
  20801. * - VertexBuffer.UV6Kind
  20802. * - VertexBuffer.ColorKind
  20803. * - VertexBuffer.MatricesIndicesKind
  20804. * - VertexBuffer.MatricesIndicesExtraKind
  20805. * - VertexBuffer.MatricesWeightsKind
  20806. * - VertexBuffer.MatricesWeightsExtraKind
  20807. * @param data defines the data source
  20808. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20809. * @param stride defines the data stride size (can be null)
  20810. * @returns the current mesh
  20811. */
  20812. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  20813. /**
  20814. * Flags an associated vertex buffer as updatable
  20815. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  20816. * - VertexBuffer.PositionKind
  20817. * - VertexBuffer.UVKind
  20818. * - VertexBuffer.UV2Kind
  20819. * - VertexBuffer.UV3Kind
  20820. * - VertexBuffer.UV4Kind
  20821. * - VertexBuffer.UV5Kind
  20822. * - VertexBuffer.UV6Kind
  20823. * - VertexBuffer.ColorKind
  20824. * - VertexBuffer.MatricesIndicesKind
  20825. * - VertexBuffer.MatricesIndicesExtraKind
  20826. * - VertexBuffer.MatricesWeightsKind
  20827. * - VertexBuffer.MatricesWeightsExtraKind
  20828. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  20829. */
  20830. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  20831. /**
  20832. * Sets the mesh global Vertex Buffer
  20833. * @param buffer defines the buffer to use
  20834. * @returns the current mesh
  20835. */
  20836. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  20837. /**
  20838. * Update a specific associated vertex buffer
  20839. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20840. * - VertexBuffer.PositionKind
  20841. * - VertexBuffer.UVKind
  20842. * - VertexBuffer.UV2Kind
  20843. * - VertexBuffer.UV3Kind
  20844. * - VertexBuffer.UV4Kind
  20845. * - VertexBuffer.UV5Kind
  20846. * - VertexBuffer.UV6Kind
  20847. * - VertexBuffer.ColorKind
  20848. * - VertexBuffer.MatricesIndicesKind
  20849. * - VertexBuffer.MatricesIndicesExtraKind
  20850. * - VertexBuffer.MatricesWeightsKind
  20851. * - VertexBuffer.MatricesWeightsExtraKind
  20852. * @param data defines the data source
  20853. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20854. * @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)
  20855. * @returns the current mesh
  20856. */
  20857. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  20858. /**
  20859. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  20860. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  20861. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  20862. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  20863. * @returns the current mesh
  20864. */
  20865. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  20866. /**
  20867. * Creates a un-shared specific occurence of the geometry for the mesh.
  20868. * @returns the current mesh
  20869. */
  20870. makeGeometryUnique(): Mesh;
  20871. /**
  20872. * Set the index buffer of this mesh
  20873. * @param indices defines the source data
  20874. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  20875. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  20876. * @returns the current mesh
  20877. */
  20878. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  20879. /**
  20880. * Update the current index buffer
  20881. * @param indices defines the source data
  20882. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  20883. * @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)
  20884. * @returns the current mesh
  20885. */
  20886. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  20887. /**
  20888. * Invert the geometry to move from a right handed system to a left handed one.
  20889. * @returns the current mesh
  20890. */
  20891. toLeftHanded(): Mesh;
  20892. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  20893. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  20894. /**
  20895. * Registers for this mesh a javascript function called just before the rendering process
  20896. * @param func defines the function to call before rendering this mesh
  20897. * @returns the current mesh
  20898. */
  20899. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20900. /**
  20901. * Disposes a previously registered javascript function called before the rendering
  20902. * @param func defines the function to remove
  20903. * @returns the current mesh
  20904. */
  20905. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  20906. /**
  20907. * Registers for this mesh a javascript function called just after the rendering is complete
  20908. * @param func defines the function to call after rendering this mesh
  20909. * @returns the current mesh
  20910. */
  20911. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20912. /**
  20913. * Disposes a previously registered javascript function called after the rendering.
  20914. * @param func defines the function to remove
  20915. * @returns the current mesh
  20916. */
  20917. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  20918. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  20919. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  20920. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  20921. /** @hidden */ private _freeze(): void;
  20922. /** @hidden */ private _unFreeze(): void;
  20923. /**
  20924. * 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
  20925. * @param subMesh defines the subMesh to render
  20926. * @param enableAlphaMode defines if alpha mode can be changed
  20927. * @returns the current mesh
  20928. */
  20929. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  20930. private _onBeforeDraw;
  20931. /**
  20932. * Renormalize the mesh and patch it up if there are no weights
  20933. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  20934. * However in the case of zero weights then we set just a single influence to 1.
  20935. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  20936. */
  20937. cleanMatrixWeights(): void;
  20938. private normalizeSkinFourWeights;
  20939. private normalizeSkinWeightsAndExtra;
  20940. /**
  20941. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  20942. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  20943. * the user know there was an issue with importing the mesh
  20944. * @returns a validation object with skinned, valid and report string
  20945. */
  20946. validateSkinning(): {
  20947. skinned: boolean;
  20948. valid: boolean;
  20949. report: string;
  20950. };
  20951. /** @hidden */ private _checkDelayState(): Mesh;
  20952. private _queueLoad;
  20953. /**
  20954. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  20955. * A mesh is in the frustum if its bounding box intersects the frustum
  20956. * @param frustumPlanes defines the frustum to test
  20957. * @returns true if the mesh is in the frustum planes
  20958. */
  20959. isInFrustum(frustumPlanes: Plane[]): boolean;
  20960. /**
  20961. * Sets the mesh material by the material or multiMaterial `id` property
  20962. * @param id is a string identifying the material or the multiMaterial
  20963. * @returns the current mesh
  20964. */
  20965. setMaterialByID(id: string): Mesh;
  20966. /**
  20967. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  20968. * @returns an array of IAnimatable
  20969. */
  20970. getAnimatables(): IAnimatable[];
  20971. /**
  20972. * Modifies the mesh geometry according to the passed transformation matrix.
  20973. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  20974. * The mesh normals are modified using the same transformation.
  20975. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20976. * @param transform defines the transform matrix to use
  20977. * @see http://doc.babylonjs.com/resources/baking_transformations
  20978. * @returns the current mesh
  20979. */
  20980. bakeTransformIntoVertices(transform: Matrix): Mesh;
  20981. /**
  20982. * Modifies the mesh geometry according to its own current World Matrix.
  20983. * The mesh World Matrix is then reset.
  20984. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  20985. * Note that, under the hood, this method sets a new VertexBuffer each call.
  20986. * @see http://doc.babylonjs.com/resources/baking_transformations
  20987. * @returns the current mesh
  20988. */
  20989. bakeCurrentTransformIntoVertices(): Mesh;
  20990. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  20991. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  20992. /** @hidden */ private _generatePointsArray(): boolean;
  20993. /**
  20994. * Returns a new Mesh object generated from the current mesh properties.
  20995. * This method must not get confused with createInstance()
  20996. * @param name is a string, the name given to the new mesh
  20997. * @param newParent can be any Node object (default `null`)
  20998. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  20999. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21000. * @returns a new mesh
  21001. */
  21002. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21003. /**
  21004. * Releases resources associated with this mesh.
  21005. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21006. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21007. */
  21008. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21009. /**
  21010. * Modifies the mesh geometry according to a displacement map.
  21011. * 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.
  21012. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21013. * @param url is a string, the URL from the image file is to be downloaded.
  21014. * @param minHeight is the lower limit of the displacement.
  21015. * @param maxHeight is the upper limit of the displacement.
  21016. * @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.
  21017. * @param uvOffset is an optional vector2 used to offset UV.
  21018. * @param uvScale is an optional vector2 used to scale UV.
  21019. * @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.
  21020. * @returns the Mesh.
  21021. */
  21022. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21023. /**
  21024. * Modifies the mesh geometry according to a displacementMap buffer.
  21025. * 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.
  21026. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21027. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21028. * @param heightMapWidth is the width of the buffer image.
  21029. * @param heightMapHeight is the height of the buffer image.
  21030. * @param minHeight is the lower limit of the displacement.
  21031. * @param maxHeight is the upper limit of the displacement.
  21032. * @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.
  21033. * @param uvOffset is an optional vector2 used to offset UV.
  21034. * @param uvScale is an optional vector2 used to scale UV.
  21035. * @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.
  21036. * @returns the Mesh.
  21037. */
  21038. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21039. /**
  21040. * Modify the mesh to get a flat shading rendering.
  21041. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21042. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21043. * @returns current mesh
  21044. */
  21045. convertToFlatShadedMesh(): Mesh;
  21046. /**
  21047. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21048. * In other words, more vertices, no more indices and a single bigger VBO.
  21049. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21050. * @returns current mesh
  21051. */
  21052. convertToUnIndexedMesh(): Mesh;
  21053. /**
  21054. * Inverses facet orientations.
  21055. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21056. * @param flipNormals will also inverts the normals
  21057. * @returns current mesh
  21058. */
  21059. flipFaces(flipNormals?: boolean): Mesh;
  21060. /**
  21061. * Increase the number of facets and hence vertices in a mesh
  21062. * Vertex normals are interpolated from existing vertex normals
  21063. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21064. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21065. */
  21066. increaseVertices(numberPerEdge: number): void;
  21067. /**
  21068. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21069. * This will undo any application of covertToFlatShadedMesh
  21070. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21071. */
  21072. forceSharedVertices(): void;
  21073. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21074. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21075. /**
  21076. * Creates a new InstancedMesh object from the mesh model.
  21077. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21078. * @param name defines the name of the new instance
  21079. * @returns a new InstancedMesh
  21080. */
  21081. createInstance(name: string): InstancedMesh;
  21082. /**
  21083. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21084. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21085. * @returns the current mesh
  21086. */
  21087. synchronizeInstances(): Mesh;
  21088. /**
  21089. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21090. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21091. * This should be used together with the simplification to avoid disappearing triangles.
  21092. * @param successCallback an optional success callback to be called after the optimization finished.
  21093. * @returns the current mesh
  21094. */
  21095. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21096. /**
  21097. * Serialize current mesh
  21098. * @param serializationObject defines the object which will receive the serialization data
  21099. */
  21100. serialize(serializationObject: any): void;
  21101. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  21102. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21103. /**
  21104. * Returns a new Mesh object parsed from the source provided.
  21105. * @param parsedMesh is the source
  21106. * @param scene defines the hosting scene
  21107. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21108. * @returns a new Mesh
  21109. */
  21110. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21111. /**
  21112. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21113. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21114. * @param name defines the name of the mesh to create
  21115. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21116. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21117. * @param closePath creates a seam between the first and the last points of each path of the path array
  21118. * @param offset is taken in account only if the `pathArray` is containing a single path
  21119. * @param scene defines the hosting scene
  21120. * @param updatable defines if the mesh must be flagged as updatable
  21121. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21122. * @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)
  21123. * @returns a new Mesh
  21124. */
  21125. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21126. /**
  21127. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21128. * @param name defines the name of the mesh to create
  21129. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21130. * @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
  21131. * @param scene defines the hosting scene
  21132. * @param updatable defines if the mesh must be flagged as updatable
  21133. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21134. * @returns a new Mesh
  21135. */
  21136. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21137. /**
  21138. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21139. * @param name defines the name of the mesh to create
  21140. * @param size sets the size (float) of each box side (default 1)
  21141. * @param scene defines the hosting scene
  21142. * @param updatable defines if the mesh must be flagged as updatable
  21143. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21144. * @returns a new Mesh
  21145. */
  21146. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21147. /**
  21148. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21149. * @param name defines the name of the mesh to create
  21150. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21151. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21152. * @param scene defines the hosting scene
  21153. * @param updatable defines if the mesh must be flagged as updatable
  21154. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21155. * @returns a new Mesh
  21156. */
  21157. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21158. /**
  21159. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21160. * @param name defines the name of the mesh to create
  21161. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21162. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21163. * @param scene defines the hosting scene
  21164. * @returns a new Mesh
  21165. */
  21166. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21167. /**
  21168. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21169. * @param name defines the name of the mesh to create
  21170. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21171. * @param diameterTop set the top cap diameter (floats, default 1)
  21172. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21173. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21174. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21175. * @param scene defines the hosting scene
  21176. * @param updatable defines if the mesh must be flagged as updatable
  21177. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21178. * @returns a new Mesh
  21179. */
  21180. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21181. /**
  21182. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21183. * @param name defines the name of the mesh to create
  21184. * @param diameter sets the diameter size (float) of the torus (default 1)
  21185. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21186. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21187. * @param scene defines the hosting scene
  21188. * @param updatable defines if the mesh must be flagged as updatable
  21189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21190. * @returns a new Mesh
  21191. */
  21192. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21193. /**
  21194. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21195. * @param name defines the name of the mesh to create
  21196. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21197. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21198. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21199. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21200. * @param p the number of windings on X axis (positive integers, default 2)
  21201. * @param q the number of windings on Y axis (positive integers, default 3)
  21202. * @param scene defines the hosting scene
  21203. * @param updatable defines if the mesh must be flagged as updatable
  21204. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21205. * @returns a new Mesh
  21206. */
  21207. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21208. /**
  21209. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21210. * @param name defines the name of the mesh to create
  21211. * @param points is an array successive Vector3
  21212. * @param scene defines the hosting scene
  21213. * @param updatable defines if the mesh must be flagged as updatable
  21214. * @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).
  21215. * @returns a new Mesh
  21216. */
  21217. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21218. /**
  21219. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21220. * @param name defines the name of the mesh to create
  21221. * @param points is an array successive Vector3
  21222. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21223. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21224. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21225. * @param scene defines the hosting scene
  21226. * @param updatable defines if the mesh must be flagged as updatable
  21227. * @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)
  21228. * @returns a new Mesh
  21229. */
  21230. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21231. /**
  21232. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21233. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21234. * 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.
  21235. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21236. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21237. * Remember you can only change the shape positions, not their number when updating a polygon.
  21238. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21239. * @param name defines the name of the mesh to create
  21240. * @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
  21241. * @param scene defines the hosting scene
  21242. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21243. * @param updatable defines if the mesh must be flagged as updatable
  21244. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21245. * @param earcutInjection can be used to inject your own earcut reference
  21246. * @returns a new Mesh
  21247. */
  21248. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21249. /**
  21250. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21251. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21252. * @param name defines the name of the mesh to create
  21253. * @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
  21254. * @param depth defines the height of extrusion
  21255. * @param scene defines the hosting scene
  21256. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21257. * @param updatable defines if the mesh must be flagged as updatable
  21258. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21259. * @param earcutInjection can be used to inject your own earcut reference
  21260. * @returns a new Mesh
  21261. */
  21262. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21263. /**
  21264. * Creates an extruded shape mesh.
  21265. * 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
  21266. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21267. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21268. * @param name defines the name of the mesh to create
  21269. * @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
  21270. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21271. * @param scale is the value to scale the shape
  21272. * @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
  21273. * @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
  21274. * @param scene defines the hosting scene
  21275. * @param updatable defines if the mesh must be flagged as updatable
  21276. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21277. * @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)
  21278. * @returns a new Mesh
  21279. */
  21280. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21281. /**
  21282. * Creates an custom extruded shape mesh.
  21283. * The custom extrusion is a parametric shape.
  21284. * It has no predefined shape. Its final shape will depend on the input parameters.
  21285. * Please consider using the same method from the MeshBuilder class instead
  21286. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21287. * @param name defines the name of the mesh to create
  21288. * @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
  21289. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  21290. * @param scaleFunction is a custom Javascript function called on each path point
  21291. * @param rotationFunction is a custom Javascript function called on each path point
  21292. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  21293. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  21294. * @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
  21295. * @param scene defines the hosting scene
  21296. * @param updatable defines if the mesh must be flagged as updatable
  21297. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21298. * @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)
  21299. * @returns a new Mesh
  21300. */
  21301. 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;
  21302. /**
  21303. * Creates lathe mesh.
  21304. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  21305. * Please consider using the same method from the MeshBuilder class instead
  21306. * @param name defines the name of the mesh to create
  21307. * @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
  21308. * @param radius is the radius value of the lathe
  21309. * @param tessellation is the side number of the lathe.
  21310. * @param scene defines the hosting scene
  21311. * @param updatable defines if the mesh must be flagged as updatable
  21312. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21313. * @returns a new Mesh
  21314. */
  21315. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21316. /**
  21317. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  21318. * @param name defines the name of the mesh to create
  21319. * @param size sets the size (float) of both sides of the plane at once (default 1)
  21320. * @param scene defines the hosting scene
  21321. * @param updatable defines if the mesh must be flagged as updatable
  21322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21323. * @returns a new Mesh
  21324. */
  21325. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21326. /**
  21327. * Creates a ground mesh.
  21328. * Please consider using the same method from the MeshBuilder class instead
  21329. * @param name defines the name of the mesh to create
  21330. * @param width set the width of the ground
  21331. * @param height set the height of the ground
  21332. * @param subdivisions sets the number of subdivisions per side
  21333. * @param scene defines the hosting scene
  21334. * @param updatable defines if the mesh must be flagged as updatable
  21335. * @returns a new Mesh
  21336. */
  21337. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  21338. /**
  21339. * Creates a tiled ground mesh.
  21340. * Please consider using the same method from the MeshBuilder class instead
  21341. * @param name defines the name of the mesh to create
  21342. * @param xmin set the ground minimum X coordinate
  21343. * @param zmin set the ground minimum Y coordinate
  21344. * @param xmax set the ground maximum X coordinate
  21345. * @param zmax set the ground maximum Z coordinate
  21346. * @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
  21347. * @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
  21348. * @param scene defines the hosting scene
  21349. * @param updatable defines if the mesh must be flagged as updatable
  21350. * @returns a new Mesh
  21351. */
  21352. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  21353. w: number;
  21354. h: number;
  21355. }, precision: {
  21356. w: number;
  21357. h: number;
  21358. }, scene: Scene, updatable?: boolean): Mesh;
  21359. /**
  21360. * Creates a ground mesh from a height map.
  21361. * Please consider using the same method from the MeshBuilder class instead
  21362. * @see http://doc.babylonjs.com/babylon101/height_map
  21363. * @param name defines the name of the mesh to create
  21364. * @param url sets the URL of the height map image resource
  21365. * @param width set the ground width size
  21366. * @param height set the ground height size
  21367. * @param subdivisions sets the number of subdivision per side
  21368. * @param minHeight is the minimum altitude on the ground
  21369. * @param maxHeight is the maximum altitude on the ground
  21370. * @param scene defines the hosting scene
  21371. * @param updatable defines if the mesh must be flagged as updatable
  21372. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  21373. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  21374. * @returns a new Mesh
  21375. */
  21376. 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;
  21377. /**
  21378. * Creates a tube mesh.
  21379. * The tube is a parametric shape.
  21380. * It has no predefined shape. Its final shape will depend on the input parameters.
  21381. * Please consider using the same method from the MeshBuilder class instead
  21382. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21383. * @param name defines the name of the mesh to create
  21384. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  21385. * @param radius sets the tube radius size
  21386. * @param tessellation is the number of sides on the tubular surface
  21387. * @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
  21388. * @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
  21389. * @param scene defines the hosting scene
  21390. * @param updatable defines if the mesh must be flagged as updatable
  21391. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21392. * @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)
  21393. * @returns a new Mesh
  21394. */
  21395. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  21396. (i: number, distance: number): number;
  21397. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21398. /**
  21399. * Creates a polyhedron mesh.
  21400. * Please consider using the same method from the MeshBuilder class instead.
  21401. * * 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
  21402. * * The parameter `size` (positive float, default 1) sets the polygon size
  21403. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  21404. * * 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`
  21405. * * 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
  21406. * * 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)`)
  21407. * * 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
  21408. * * 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
  21409. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21410. * * If you create a double-sided mesh, you can choose what parts of 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
  21411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21412. * @param name defines the name of the mesh to create
  21413. * @param options defines the options used to create the mesh
  21414. * @param scene defines the hosting scene
  21415. * @returns a new Mesh
  21416. */
  21417. static CreatePolyhedron(name: string, options: {
  21418. type?: number;
  21419. size?: number;
  21420. sizeX?: number;
  21421. sizeY?: number;
  21422. sizeZ?: number;
  21423. custom?: any;
  21424. faceUV?: Vector4[];
  21425. faceColors?: Color4[];
  21426. updatable?: boolean;
  21427. sideOrientation?: number;
  21428. }, scene: Scene): Mesh;
  21429. /**
  21430. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  21431. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  21432. * * 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`)
  21433. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  21434. * * 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
  21435. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21436. * * If you create a double-sided mesh, you can choose what parts of 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
  21437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  21438. * @param name defines the name of the mesh
  21439. * @param options defines the options used to create the mesh
  21440. * @param scene defines the hosting scene
  21441. * @returns a new Mesh
  21442. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  21443. */
  21444. static CreateIcoSphere(name: string, options: {
  21445. radius?: number;
  21446. flat?: boolean;
  21447. subdivisions?: number;
  21448. sideOrientation?: number;
  21449. updatable?: boolean;
  21450. }, scene: Scene): Mesh;
  21451. /**
  21452. * Creates a decal mesh.
  21453. * Please consider using the same method from the MeshBuilder class instead.
  21454. * A decal is a mesh usually applied as a model onto the surface of another mesh
  21455. * @param name defines the name of the mesh
  21456. * @param sourceMesh defines the mesh receiving the decal
  21457. * @param position sets the position of the decal in world coordinates
  21458. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  21459. * @param size sets the decal scaling
  21460. * @param angle sets the angle to rotate the decal
  21461. * @returns a new Mesh
  21462. */
  21463. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  21464. /**
  21465. * Prepare internal position array for software CPU skinning
  21466. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  21467. */
  21468. setPositionsForCPUSkinning(): Float32Array;
  21469. /**
  21470. * Prepare internal normal array for software CPU skinning
  21471. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  21472. */
  21473. setNormalsForCPUSkinning(): Float32Array;
  21474. /**
  21475. * Updates the vertex buffer by applying transformation from the bones
  21476. * @param skeleton defines the skeleton to apply to current mesh
  21477. * @returns the current mesh
  21478. */
  21479. applySkeleton(skeleton: Skeleton): Mesh;
  21480. /**
  21481. * 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
  21482. * @param meshes defines the list of meshes to scan
  21483. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  21484. */
  21485. static MinMax(meshes: AbstractMesh[]): {
  21486. min: Vector3;
  21487. max: Vector3;
  21488. };
  21489. /**
  21490. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  21491. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  21492. * @returns a vector3
  21493. */
  21494. static Center(meshesOrMinMaxVector: {
  21495. min: Vector3;
  21496. max: Vector3;
  21497. } | AbstractMesh[]): Vector3;
  21498. /**
  21499. * Merge the array of meshes into a single mesh for performance reasons.
  21500. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  21501. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  21502. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  21503. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  21504. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  21505. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  21506. * @returns a new mesh
  21507. */
  21508. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  21509. /** @hidden */
  21510. addInstance(instance: InstancedMesh): void;
  21511. /** @hidden */
  21512. removeInstance(instance: InstancedMesh): void;
  21513. }
  21514. }
  21515. declare module BABYLON {
  21516. /**
  21517. * Base class for the main features of a material in Babylon.js
  21518. */
  21519. export class Material implements IAnimatable {
  21520. /**
  21521. * Returns the triangle fill mode
  21522. */
  21523. static readonly TriangleFillMode: number;
  21524. /**
  21525. * Returns the wireframe mode
  21526. */
  21527. static readonly WireFrameFillMode: number;
  21528. /**
  21529. * Returns the point fill mode
  21530. */
  21531. static readonly PointFillMode: number;
  21532. /**
  21533. * Returns the point list draw mode
  21534. */
  21535. static readonly PointListDrawMode: number;
  21536. /**
  21537. * Returns the line list draw mode
  21538. */
  21539. static readonly LineListDrawMode: number;
  21540. /**
  21541. * Returns the line loop draw mode
  21542. */
  21543. static readonly LineLoopDrawMode: number;
  21544. /**
  21545. * Returns the line strip draw mode
  21546. */
  21547. static readonly LineStripDrawMode: number;
  21548. /**
  21549. * Returns the triangle strip draw mode
  21550. */
  21551. static readonly TriangleStripDrawMode: number;
  21552. /**
  21553. * Returns the triangle fan draw mode
  21554. */
  21555. static readonly TriangleFanDrawMode: number;
  21556. /**
  21557. * Stores the clock-wise side orientation
  21558. */
  21559. static readonly ClockWiseSideOrientation: number;
  21560. /**
  21561. * Stores the counter clock-wise side orientation
  21562. */
  21563. static readonly CounterClockWiseSideOrientation: number;
  21564. /**
  21565. * The dirty texture flag value
  21566. */
  21567. static readonly TextureDirtyFlag: number;
  21568. /**
  21569. * The dirty light flag value
  21570. */
  21571. static readonly LightDirtyFlag: number;
  21572. /**
  21573. * The dirty fresnel flag value
  21574. */
  21575. static readonly FresnelDirtyFlag: number;
  21576. /**
  21577. * The dirty attribute flag value
  21578. */
  21579. static readonly AttributesDirtyFlag: number;
  21580. /**
  21581. * The dirty misc flag value
  21582. */
  21583. static readonly MiscDirtyFlag: number;
  21584. /**
  21585. * The all dirty flag value
  21586. */
  21587. static readonly AllDirtyFlag: number;
  21588. /**
  21589. * The ID of the material
  21590. */
  21591. id: string;
  21592. /**
  21593. * Gets or sets the unique id of the material
  21594. */
  21595. uniqueId: number;
  21596. /**
  21597. * The name of the material
  21598. */
  21599. name: string;
  21600. /**
  21601. * Gets or sets user defined metadata
  21602. */
  21603. metadata: any;
  21604. /**
  21605. * For internal use only. Please do not use.
  21606. */
  21607. reservedDataStore: any;
  21608. /**
  21609. * Specifies if the ready state should be checked on each call
  21610. */
  21611. checkReadyOnEveryCall: boolean;
  21612. /**
  21613. * Specifies if the ready state should be checked once
  21614. */
  21615. checkReadyOnlyOnce: boolean;
  21616. /**
  21617. * The state of the material
  21618. */
  21619. state: string;
  21620. /**
  21621. * The alpha value of the material
  21622. */
  21623. protected _alpha: number;
  21624. /**
  21625. * List of inspectable custom properties (used by the Inspector)
  21626. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21627. */
  21628. inspectableCustomProperties: IInspectable[];
  21629. /**
  21630. * Sets the alpha value of the material
  21631. */
  21632. /**
  21633. * Gets the alpha value of the material
  21634. */
  21635. alpha: number;
  21636. /**
  21637. * Specifies if back face culling is enabled
  21638. */
  21639. protected _backFaceCulling: boolean;
  21640. /**
  21641. * Sets the back-face culling state
  21642. */
  21643. /**
  21644. * Gets the back-face culling state
  21645. */
  21646. backFaceCulling: boolean;
  21647. /**
  21648. * Stores the value for side orientation
  21649. */
  21650. sideOrientation: number;
  21651. /**
  21652. * Callback triggered when the material is compiled
  21653. */
  21654. onCompiled: Nullable<(effect: Effect) => void>;
  21655. /**
  21656. * Callback triggered when an error occurs
  21657. */
  21658. onError: Nullable<(effect: Effect, errors: string) => void>;
  21659. /**
  21660. * Callback triggered to get the render target textures
  21661. */
  21662. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21663. /**
  21664. * Gets a boolean indicating that current material needs to register RTT
  21665. */
  21666. readonly hasRenderTargetTextures: boolean;
  21667. /**
  21668. * Specifies if the material should be serialized
  21669. */
  21670. doNotSerialize: boolean;
  21671. /**
  21672. * @hidden
  21673. */ private _storeEffectOnSubMeshes: boolean;
  21674. /**
  21675. * Stores the animations for the material
  21676. */
  21677. animations: Nullable<Array<Animation>>;
  21678. /**
  21679. * An event triggered when the material is disposed
  21680. */
  21681. onDisposeObservable: Observable<Material>;
  21682. /**
  21683. * An observer which watches for dispose events
  21684. */
  21685. private _onDisposeObserver;
  21686. private _onUnBindObservable;
  21687. /**
  21688. * Called during a dispose event
  21689. */
  21690. onDispose: () => void;
  21691. private _onBindObservable;
  21692. /**
  21693. * An event triggered when the material is bound
  21694. */
  21695. readonly onBindObservable: Observable<AbstractMesh>;
  21696. /**
  21697. * An observer which watches for bind events
  21698. */
  21699. private _onBindObserver;
  21700. /**
  21701. * Called during a bind event
  21702. */
  21703. onBind: (Mesh: AbstractMesh) => void;
  21704. /**
  21705. * An event triggered when the material is unbound
  21706. */
  21707. readonly onUnBindObservable: Observable<Material>;
  21708. /**
  21709. * Stores the value of the alpha mode
  21710. */
  21711. private _alphaMode;
  21712. /**
  21713. * Sets the value of the alpha mode.
  21714. *
  21715. * | Value | Type | Description |
  21716. * | --- | --- | --- |
  21717. * | 0 | ALPHA_DISABLE | |
  21718. * | 1 | ALPHA_ADD | |
  21719. * | 2 | ALPHA_COMBINE | |
  21720. * | 3 | ALPHA_SUBTRACT | |
  21721. * | 4 | ALPHA_MULTIPLY | |
  21722. * | 5 | ALPHA_MAXIMIZED | |
  21723. * | 6 | ALPHA_ONEONE | |
  21724. * | 7 | ALPHA_PREMULTIPLIED | |
  21725. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21726. * | 9 | ALPHA_INTERPOLATE | |
  21727. * | 10 | ALPHA_SCREENMODE | |
  21728. *
  21729. */
  21730. /**
  21731. * Gets the value of the alpha mode
  21732. */
  21733. alphaMode: number;
  21734. /**
  21735. * Stores the state of the need depth pre-pass value
  21736. */
  21737. private _needDepthPrePass;
  21738. /**
  21739. * Sets the need depth pre-pass value
  21740. */
  21741. /**
  21742. * Gets the depth pre-pass value
  21743. */
  21744. needDepthPrePass: boolean;
  21745. /**
  21746. * Specifies if depth writing should be disabled
  21747. */
  21748. disableDepthWrite: boolean;
  21749. /**
  21750. * Specifies if depth writing should be forced
  21751. */
  21752. forceDepthWrite: boolean;
  21753. /**
  21754. * Specifies if there should be a separate pass for culling
  21755. */
  21756. separateCullingPass: boolean;
  21757. /**
  21758. * Stores the state specifing if fog should be enabled
  21759. */
  21760. private _fogEnabled;
  21761. /**
  21762. * Sets the state for enabling fog
  21763. */
  21764. /**
  21765. * Gets the value of the fog enabled state
  21766. */
  21767. fogEnabled: boolean;
  21768. /**
  21769. * Stores the size of points
  21770. */
  21771. pointSize: number;
  21772. /**
  21773. * Stores the z offset value
  21774. */
  21775. zOffset: number;
  21776. /**
  21777. * Gets a value specifying if wireframe mode is enabled
  21778. */
  21779. /**
  21780. * Sets the state of wireframe mode
  21781. */
  21782. wireframe: boolean;
  21783. /**
  21784. * Gets the value specifying if point clouds are enabled
  21785. */
  21786. /**
  21787. * Sets the state of point cloud mode
  21788. */
  21789. pointsCloud: boolean;
  21790. /**
  21791. * Gets the material fill mode
  21792. */
  21793. /**
  21794. * Sets the material fill mode
  21795. */
  21796. fillMode: number;
  21797. /**
  21798. * @hidden
  21799. * Stores the effects for the material
  21800. */ private _effect: Nullable<Effect>;
  21801. /**
  21802. * @hidden
  21803. * Specifies if the material was previously ready
  21804. */ private _wasPreviouslyReady: boolean;
  21805. /**
  21806. * Specifies if uniform buffers should be used
  21807. */
  21808. private _useUBO;
  21809. /**
  21810. * Stores a reference to the scene
  21811. */
  21812. private _scene;
  21813. /**
  21814. * Stores the fill mode state
  21815. */
  21816. private _fillMode;
  21817. /**
  21818. * Specifies if the depth write state should be cached
  21819. */
  21820. private _cachedDepthWriteState;
  21821. /**
  21822. * Stores the uniform buffer
  21823. */
  21824. protected _uniformBuffer: UniformBuffer;
  21825. /** @hidden */ private _indexInSceneMaterialArray: number;
  21826. /** @hidden */
  21827. meshMap: Nullable<{
  21828. [id: string]: AbstractMesh | undefined;
  21829. }>;
  21830. /**
  21831. * Creates a material instance
  21832. * @param name defines the name of the material
  21833. * @param scene defines the scene to reference
  21834. * @param doNotAdd specifies if the material should be added to the scene
  21835. */
  21836. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21837. /**
  21838. * Returns a string representation of the current material
  21839. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21840. * @returns a string with material information
  21841. */
  21842. toString(fullDetails?: boolean): string;
  21843. /**
  21844. * Gets the class name of the material
  21845. * @returns a string with the class name of the material
  21846. */
  21847. getClassName(): string;
  21848. /**
  21849. * Specifies if updates for the material been locked
  21850. */
  21851. readonly isFrozen: boolean;
  21852. /**
  21853. * Locks updates for the material
  21854. */
  21855. freeze(): void;
  21856. /**
  21857. * Unlocks updates for the material
  21858. */
  21859. unfreeze(): void;
  21860. /**
  21861. * Specifies if the material is ready to be used
  21862. * @param mesh defines the mesh to check
  21863. * @param useInstances specifies if instances should be used
  21864. * @returns a boolean indicating if the material is ready to be used
  21865. */
  21866. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21867. /**
  21868. * Specifies that the submesh is ready to be used
  21869. * @param mesh defines the mesh to check
  21870. * @param subMesh defines which submesh to check
  21871. * @param useInstances specifies that instances should be used
  21872. * @returns a boolean indicating that the submesh is ready or not
  21873. */
  21874. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21875. /**
  21876. * Returns the material effect
  21877. * @returns the effect associated with the material
  21878. */
  21879. getEffect(): Nullable<Effect>;
  21880. /**
  21881. * Returns the current scene
  21882. * @returns a Scene
  21883. */
  21884. getScene(): Scene;
  21885. /**
  21886. * Specifies if the material will require alpha blending
  21887. * @returns a boolean specifying if alpha blending is needed
  21888. */
  21889. needAlphaBlending(): boolean;
  21890. /**
  21891. * Specifies if the mesh will require alpha blending
  21892. * @param mesh defines the mesh to check
  21893. * @returns a boolean specifying if alpha blending is needed for the mesh
  21894. */
  21895. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21896. /**
  21897. * Specifies if this material should be rendered in alpha test mode
  21898. * @returns a boolean specifying if an alpha test is needed.
  21899. */
  21900. needAlphaTesting(): boolean;
  21901. /**
  21902. * Gets the texture used for the alpha test
  21903. * @returns the texture to use for alpha testing
  21904. */
  21905. getAlphaTestTexture(): Nullable<BaseTexture>;
  21906. /**
  21907. * Marks the material to indicate that it needs to be re-calculated
  21908. */
  21909. markDirty(): void;
  21910. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21911. /**
  21912. * Binds the material to the mesh
  21913. * @param world defines the world transformation matrix
  21914. * @param mesh defines the mesh to bind the material to
  21915. */
  21916. bind(world: Matrix, mesh?: Mesh): void;
  21917. /**
  21918. * Binds the submesh to the material
  21919. * @param world defines the world transformation matrix
  21920. * @param mesh defines the mesh containing the submesh
  21921. * @param subMesh defines the submesh to bind the material to
  21922. */
  21923. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21924. /**
  21925. * Binds the world matrix to the material
  21926. * @param world defines the world transformation matrix
  21927. */
  21928. bindOnlyWorldMatrix(world: Matrix): void;
  21929. /**
  21930. * Binds the scene's uniform buffer to the effect.
  21931. * @param effect defines the effect to bind to the scene uniform buffer
  21932. * @param sceneUbo defines the uniform buffer storing scene data
  21933. */
  21934. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21935. /**
  21936. * Binds the view matrix to the effect
  21937. * @param effect defines the effect to bind the view matrix to
  21938. */
  21939. bindView(effect: Effect): void;
  21940. /**
  21941. * Binds the view projection matrix to the effect
  21942. * @param effect defines the effect to bind the view projection matrix to
  21943. */
  21944. bindViewProjection(effect: Effect): void;
  21945. /**
  21946. * Specifies if material alpha testing should be turned on for the mesh
  21947. * @param mesh defines the mesh to check
  21948. */
  21949. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21950. /**
  21951. * Processes to execute after binding the material to a mesh
  21952. * @param mesh defines the rendered mesh
  21953. */
  21954. protected _afterBind(mesh?: Mesh): void;
  21955. /**
  21956. * Unbinds the material from the mesh
  21957. */
  21958. unbind(): void;
  21959. /**
  21960. * Gets the active textures from the material
  21961. * @returns an array of textures
  21962. */
  21963. getActiveTextures(): BaseTexture[];
  21964. /**
  21965. * Specifies if the material uses a texture
  21966. * @param texture defines the texture to check against the material
  21967. * @returns a boolean specifying if the material uses the texture
  21968. */
  21969. hasTexture(texture: BaseTexture): boolean;
  21970. /**
  21971. * Makes a duplicate of the material, and gives it a new name
  21972. * @param name defines the new name for the duplicated material
  21973. * @returns the cloned material
  21974. */
  21975. clone(name: string): Nullable<Material>;
  21976. /**
  21977. * Gets the meshes bound to the material
  21978. * @returns an array of meshes bound to the material
  21979. */
  21980. getBindedMeshes(): AbstractMesh[];
  21981. /**
  21982. * Force shader compilation
  21983. * @param mesh defines the mesh associated with this material
  21984. * @param onCompiled defines a function to execute once the material is compiled
  21985. * @param options defines the options to configure the compilation
  21986. */
  21987. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21988. clipPlane: boolean;
  21989. }>): void;
  21990. /**
  21991. * Force shader compilation
  21992. * @param mesh defines the mesh that will use this material
  21993. * @param options defines additional options for compiling the shaders
  21994. * @returns a promise that resolves when the compilation completes
  21995. */
  21996. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21997. clipPlane: boolean;
  21998. }>): Promise<void>;
  21999. private static readonly _AllDirtyCallBack;
  22000. private static readonly _ImageProcessingDirtyCallBack;
  22001. private static readonly _TextureDirtyCallBack;
  22002. private static readonly _FresnelDirtyCallBack;
  22003. private static readonly _MiscDirtyCallBack;
  22004. private static readonly _LightsDirtyCallBack;
  22005. private static readonly _AttributeDirtyCallBack;
  22006. private static _FresnelAndMiscDirtyCallBack;
  22007. private static _TextureAndMiscDirtyCallBack;
  22008. private static readonly _DirtyCallbackArray;
  22009. private static readonly _RunDirtyCallBacks;
  22010. /**
  22011. * Marks a define in the material to indicate that it needs to be re-computed
  22012. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22013. */
  22014. markAsDirty(flag: number): void;
  22015. /**
  22016. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22017. * @param func defines a function which checks material defines against the submeshes
  22018. */
  22019. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22020. /**
  22021. * Indicates that we need to re-calculated for all submeshes
  22022. */
  22023. protected _markAllSubMeshesAsAllDirty(): void;
  22024. /**
  22025. * Indicates that image processing needs to be re-calculated for all submeshes
  22026. */
  22027. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22028. /**
  22029. * Indicates that textures need to be re-calculated for all submeshes
  22030. */
  22031. protected _markAllSubMeshesAsTexturesDirty(): void;
  22032. /**
  22033. * Indicates that fresnel needs to be re-calculated for all submeshes
  22034. */
  22035. protected _markAllSubMeshesAsFresnelDirty(): void;
  22036. /**
  22037. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22038. */
  22039. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22040. /**
  22041. * Indicates that lights need to be re-calculated for all submeshes
  22042. */
  22043. protected _markAllSubMeshesAsLightsDirty(): void;
  22044. /**
  22045. * Indicates that attributes need to be re-calculated for all submeshes
  22046. */
  22047. protected _markAllSubMeshesAsAttributesDirty(): void;
  22048. /**
  22049. * Indicates that misc needs to be re-calculated for all submeshes
  22050. */
  22051. protected _markAllSubMeshesAsMiscDirty(): void;
  22052. /**
  22053. * Indicates that textures and misc need to be re-calculated for all submeshes
  22054. */
  22055. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22056. /**
  22057. * Disposes the material
  22058. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22059. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22060. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22061. */
  22062. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22063. /** @hidden */
  22064. private releaseVertexArrayObject;
  22065. /**
  22066. * Serializes this material
  22067. * @returns the serialized material object
  22068. */
  22069. serialize(): any;
  22070. /**
  22071. * Creates a material from parsed material data
  22072. * @param parsedMaterial defines parsed material data
  22073. * @param scene defines the hosting scene
  22074. * @param rootUrl defines the root URL to use to load textures
  22075. * @returns a new material
  22076. */
  22077. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22078. }
  22079. }
  22080. declare module BABYLON {
  22081. /**
  22082. * Base class for submeshes
  22083. */
  22084. export class BaseSubMesh {
  22085. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  22086. /** @hidden */ private _materialEffect: Nullable<Effect>;
  22087. /**
  22088. * Gets associated effect
  22089. */
  22090. readonly effect: Nullable<Effect>;
  22091. /**
  22092. * Sets associated effect (effect used to render this submesh)
  22093. * @param effect defines the effect to associate with
  22094. * @param defines defines the set of defines used to compile this effect
  22095. */
  22096. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22097. }
  22098. /**
  22099. * Defines a subdivision inside a mesh
  22100. */
  22101. export class SubMesh extends BaseSubMesh implements ICullable {
  22102. /** the material index to use */
  22103. materialIndex: number;
  22104. /** vertex index start */
  22105. verticesStart: number;
  22106. /** vertices count */
  22107. verticesCount: number;
  22108. /** index start */
  22109. indexStart: number;
  22110. /** indices count */
  22111. indexCount: number;
  22112. /** @hidden */ private _linesIndexCount: number;
  22113. private _mesh;
  22114. private _renderingMesh;
  22115. private _boundingInfo;
  22116. private _linesIndexBuffer;
  22117. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  22118. /** @hidden */ private _trianglePlanes: Plane[];
  22119. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  22120. /** @hidden */ private _renderId: number;
  22121. /** @hidden */ private _alphaIndex: number;
  22122. /** @hidden */ private _distanceToCamera: number;
  22123. /** @hidden */ private _id: number;
  22124. private _currentMaterial;
  22125. /**
  22126. * Add a new submesh to a mesh
  22127. * @param materialIndex defines the material index to use
  22128. * @param verticesStart defines vertex index start
  22129. * @param verticesCount defines vertices count
  22130. * @param indexStart defines index start
  22131. * @param indexCount defines indices count
  22132. * @param mesh defines the parent mesh
  22133. * @param renderingMesh defines an optional rendering mesh
  22134. * @param createBoundingBox defines if bounding box should be created for this submesh
  22135. * @returns the new submesh
  22136. */
  22137. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22138. /**
  22139. * Creates a new submesh
  22140. * @param materialIndex defines the material index to use
  22141. * @param verticesStart defines vertex index start
  22142. * @param verticesCount defines vertices count
  22143. * @param indexStart defines index start
  22144. * @param indexCount defines indices count
  22145. * @param mesh defines the parent mesh
  22146. * @param renderingMesh defines an optional rendering mesh
  22147. * @param createBoundingBox defines if bounding box should be created for this submesh
  22148. */
  22149. constructor(
  22150. /** the material index to use */
  22151. materialIndex: number,
  22152. /** vertex index start */
  22153. verticesStart: number,
  22154. /** vertices count */
  22155. verticesCount: number,
  22156. /** index start */
  22157. indexStart: number,
  22158. /** indices count */
  22159. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22160. /**
  22161. * Returns true if this submesh covers the entire parent mesh
  22162. * @ignorenaming
  22163. */
  22164. readonly IsGlobal: boolean;
  22165. /**
  22166. * Returns the submesh BoudingInfo object
  22167. * @returns current bounding info (or mesh's one if the submesh is global)
  22168. */
  22169. getBoundingInfo(): BoundingInfo;
  22170. /**
  22171. * Sets the submesh BoundingInfo
  22172. * @param boundingInfo defines the new bounding info to use
  22173. * @returns the SubMesh
  22174. */
  22175. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22176. /**
  22177. * Returns the mesh of the current submesh
  22178. * @return the parent mesh
  22179. */
  22180. getMesh(): AbstractMesh;
  22181. /**
  22182. * Returns the rendering mesh of the submesh
  22183. * @returns the rendering mesh (could be different from parent mesh)
  22184. */
  22185. getRenderingMesh(): Mesh;
  22186. /**
  22187. * Returns the submesh material
  22188. * @returns null or the current material
  22189. */
  22190. getMaterial(): Nullable<Material>;
  22191. /**
  22192. * Sets a new updated BoundingInfo object to the submesh
  22193. * @param data defines an optional position array to use to determine the bounding info
  22194. * @returns the SubMesh
  22195. */
  22196. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22197. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  22198. /**
  22199. * Updates the submesh BoundingInfo
  22200. * @param world defines the world matrix to use to update the bounding info
  22201. * @returns the submesh
  22202. */
  22203. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22204. /**
  22205. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22206. * @param frustumPlanes defines the frustum planes
  22207. * @returns true if the submesh is intersecting with the frustum
  22208. */
  22209. isInFrustum(frustumPlanes: Plane[]): boolean;
  22210. /**
  22211. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22212. * @param frustumPlanes defines the frustum planes
  22213. * @returns true if the submesh is inside the frustum
  22214. */
  22215. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22216. /**
  22217. * Renders the submesh
  22218. * @param enableAlphaMode defines if alpha needs to be used
  22219. * @returns the submesh
  22220. */
  22221. render(enableAlphaMode: boolean): SubMesh;
  22222. /**
  22223. * @hidden
  22224. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22225. /**
  22226. * Checks if the submesh intersects with a ray
  22227. * @param ray defines the ray to test
  22228. * @returns true is the passed ray intersects the submesh bounding box
  22229. */
  22230. canIntersects(ray: Ray): boolean;
  22231. /**
  22232. * Intersects current submesh with a ray
  22233. * @param ray defines the ray to test
  22234. * @param positions defines mesh's positions array
  22235. * @param indices defines mesh's indices array
  22236. * @param fastCheck defines if only bounding info should be used
  22237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22238. * @returns intersection info or null if no intersection
  22239. */
  22240. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22241. /** @hidden */
  22242. private _intersectLines;
  22243. /** @hidden */
  22244. private _intersectUnIndexedLines;
  22245. /** @hidden */
  22246. private _intersectTriangles;
  22247. /** @hidden */
  22248. private _intersectUnIndexedTriangles;
  22249. /** @hidden */ private _rebuild(): void;
  22250. /**
  22251. * Creates a new submesh from the passed mesh
  22252. * @param newMesh defines the new hosting mesh
  22253. * @param newRenderingMesh defines an optional rendering mesh
  22254. * @returns the new submesh
  22255. */
  22256. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22257. /**
  22258. * Release associated resources
  22259. */
  22260. dispose(): void;
  22261. /**
  22262. * Gets the class name
  22263. * @returns the string "SubMesh".
  22264. */
  22265. getClassName(): string;
  22266. /**
  22267. * Creates a new submesh from indices data
  22268. * @param materialIndex the index of the main mesh material
  22269. * @param startIndex the index where to start the copy in the mesh indices array
  22270. * @param indexCount the number of indices to copy then from the startIndex
  22271. * @param mesh the main mesh to create the submesh from
  22272. * @param renderingMesh the optional rendering mesh
  22273. * @returns a new submesh
  22274. */
  22275. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22276. }
  22277. }
  22278. declare module BABYLON {
  22279. /**
  22280. * Class used to store geometry data (vertex buffers + index buffer)
  22281. */
  22282. export class Geometry implements IGetSetVerticesData {
  22283. /**
  22284. * Gets or sets the ID of the geometry
  22285. */
  22286. id: string;
  22287. /**
  22288. * Gets or sets the unique ID of the geometry
  22289. */
  22290. uniqueId: number;
  22291. /**
  22292. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22293. */
  22294. delayLoadState: number;
  22295. /**
  22296. * Gets the file containing the data to load when running in delay load state
  22297. */
  22298. delayLoadingFile: Nullable<string>;
  22299. /**
  22300. * Callback called when the geometry is updated
  22301. */
  22302. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22303. private _scene;
  22304. private _engine;
  22305. private _meshes;
  22306. private _totalVertices;
  22307. /** @hidden */ private _indices: IndicesArray;
  22308. /** @hidden */ private _vertexBuffers: {
  22309. [key: string]: VertexBuffer;
  22310. };
  22311. private _isDisposed;
  22312. private _extend;
  22313. private _boundingBias;
  22314. /** @hidden */ private _delayInfo: Array<string>;
  22315. private _indexBuffer;
  22316. private _indexBufferIsUpdatable;
  22317. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  22318. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22319. /** @hidden */ private _softwareSkinningFrameId: number;
  22320. private _vertexArrayObjects;
  22321. private _updatable;
  22322. /** @hidden */ private _positions: Nullable<Vector3[]>;
  22323. /**
  22324. * 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
  22325. */
  22326. /**
  22327. * 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
  22328. */
  22329. boundingBias: Vector2;
  22330. /**
  22331. * Static function used to attach a new empty geometry to a mesh
  22332. * @param mesh defines the mesh to attach the geometry to
  22333. * @returns the new Geometry
  22334. */
  22335. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22336. /**
  22337. * Creates a new geometry
  22338. * @param id defines the unique ID
  22339. * @param scene defines the hosting scene
  22340. * @param vertexData defines the VertexData used to get geometry data
  22341. * @param updatable defines if geometry must be updatable (false by default)
  22342. * @param mesh defines the mesh that will be associated with the geometry
  22343. */
  22344. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22345. /**
  22346. * Gets the current extend of the geometry
  22347. */
  22348. readonly extend: {
  22349. minimum: Vector3;
  22350. maximum: Vector3;
  22351. };
  22352. /**
  22353. * Gets the hosting scene
  22354. * @returns the hosting Scene
  22355. */
  22356. getScene(): Scene;
  22357. /**
  22358. * Gets the hosting engine
  22359. * @returns the hosting Engine
  22360. */
  22361. getEngine(): Engine;
  22362. /**
  22363. * Defines if the geometry is ready to use
  22364. * @returns true if the geometry is ready to be used
  22365. */
  22366. isReady(): boolean;
  22367. /**
  22368. * Gets a value indicating that the geometry should not be serialized
  22369. */
  22370. readonly doNotSerialize: boolean;
  22371. /** @hidden */ private _rebuild(): void;
  22372. /**
  22373. * Affects all geometry data in one call
  22374. * @param vertexData defines the geometry data
  22375. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22376. */
  22377. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22378. /**
  22379. * Set specific vertex data
  22380. * @param kind defines the data kind (Position, normal, etc...)
  22381. * @param data defines the vertex data to use
  22382. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22383. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22384. */
  22385. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22386. /**
  22387. * Removes a specific vertex data
  22388. * @param kind defines the data kind (Position, normal, etc...)
  22389. */
  22390. removeVerticesData(kind: string): void;
  22391. /**
  22392. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22393. * @param buffer defines the vertex buffer to use
  22394. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22395. */
  22396. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22397. /**
  22398. * Update a specific vertex buffer
  22399. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22400. * It will do nothing if the buffer is not updatable
  22401. * @param kind defines the data kind (Position, normal, etc...)
  22402. * @param data defines the data to use
  22403. * @param offset defines the offset in the target buffer where to store the data
  22404. * @param useBytes set to true if the offset is in bytes
  22405. */
  22406. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22407. /**
  22408. * Update a specific vertex buffer
  22409. * This function will create a new buffer if the current one is not updatable
  22410. * @param kind defines the data kind (Position, normal, etc...)
  22411. * @param data defines the data to use
  22412. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22413. */
  22414. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22415. private _updateBoundingInfo;
  22416. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22417. /**
  22418. * Gets total number of vertices
  22419. * @returns the total number of vertices
  22420. */
  22421. getTotalVertices(): number;
  22422. /**
  22423. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22424. * @param kind defines the data kind (Position, normal, etc...)
  22425. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22426. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22427. * @returns a float array containing vertex data
  22428. */
  22429. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22430. /**
  22431. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22432. * @param kind defines the data kind (Position, normal, etc...)
  22433. * @returns true if the vertex buffer with the specified kind is updatable
  22434. */
  22435. isVertexBufferUpdatable(kind: string): boolean;
  22436. /**
  22437. * Gets a specific vertex buffer
  22438. * @param kind defines the data kind (Position, normal, etc...)
  22439. * @returns a VertexBuffer
  22440. */
  22441. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22442. /**
  22443. * Returns all vertex buffers
  22444. * @return an object holding all vertex buffers indexed by kind
  22445. */
  22446. getVertexBuffers(): Nullable<{
  22447. [key: string]: VertexBuffer;
  22448. }>;
  22449. /**
  22450. * Gets a boolean indicating if specific vertex buffer is present
  22451. * @param kind defines the data kind (Position, normal, etc...)
  22452. * @returns true if data is present
  22453. */
  22454. isVerticesDataPresent(kind: string): boolean;
  22455. /**
  22456. * Gets a list of all attached data kinds (Position, normal, etc...)
  22457. * @returns a list of string containing all kinds
  22458. */
  22459. getVerticesDataKinds(): string[];
  22460. /**
  22461. * Update index buffer
  22462. * @param indices defines the indices to store in the index buffer
  22463. * @param offset defines the offset in the target buffer where to store the data
  22464. * @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)
  22465. */
  22466. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22467. /**
  22468. * Creates a new index buffer
  22469. * @param indices defines the indices to store in the index buffer
  22470. * @param totalVertices defines the total number of vertices (could be null)
  22471. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22472. */
  22473. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22474. /**
  22475. * Return the total number of indices
  22476. * @returns the total number of indices
  22477. */
  22478. getTotalIndices(): number;
  22479. /**
  22480. * Gets the index buffer array
  22481. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22482. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22483. * @returns the index buffer array
  22484. */
  22485. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22486. /**
  22487. * Gets the index buffer
  22488. * @return the index buffer
  22489. */
  22490. getIndexBuffer(): Nullable<DataBuffer>;
  22491. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22492. /**
  22493. * Release the associated resources for a specific mesh
  22494. * @param mesh defines the source mesh
  22495. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22496. */
  22497. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22498. /**
  22499. * Apply current geometry to a given mesh
  22500. * @param mesh defines the mesh to apply geometry to
  22501. */
  22502. applyToMesh(mesh: Mesh): void;
  22503. private _updateExtend;
  22504. private _applyToMesh;
  22505. private notifyUpdate;
  22506. /**
  22507. * Load the geometry if it was flagged as delay loaded
  22508. * @param scene defines the hosting scene
  22509. * @param onLoaded defines a callback called when the geometry is loaded
  22510. */
  22511. load(scene: Scene, onLoaded?: () => void): void;
  22512. private _queueLoad;
  22513. /**
  22514. * Invert the geometry to move from a right handed system to a left handed one.
  22515. */
  22516. toLeftHanded(): void;
  22517. /** @hidden */ private _resetPointsArrayCache(): void;
  22518. /** @hidden */ private _generatePointsArray(): boolean;
  22519. /**
  22520. * Gets a value indicating if the geometry is disposed
  22521. * @returns true if the geometry was disposed
  22522. */
  22523. isDisposed(): boolean;
  22524. private _disposeVertexArrayObjects;
  22525. /**
  22526. * Free all associated resources
  22527. */
  22528. dispose(): void;
  22529. /**
  22530. * Clone the current geometry into a new geometry
  22531. * @param id defines the unique ID of the new geometry
  22532. * @returns a new geometry object
  22533. */
  22534. copy(id: string): Geometry;
  22535. /**
  22536. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22537. * @return a JSON representation of the current geometry data (without the vertices data)
  22538. */
  22539. serialize(): any;
  22540. private toNumberArray;
  22541. /**
  22542. * Serialize all vertices data into a JSON oject
  22543. * @returns a JSON representation of the current geometry data
  22544. */
  22545. serializeVerticeData(): any;
  22546. /**
  22547. * Extracts a clone of a mesh geometry
  22548. * @param mesh defines the source mesh
  22549. * @param id defines the unique ID of the new geometry object
  22550. * @returns the new geometry object
  22551. */
  22552. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22553. /**
  22554. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22555. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22556. * Be aware Math.random() could cause collisions, but:
  22557. * "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"
  22558. * @returns a string containing a new GUID
  22559. */
  22560. static RandomId(): string;
  22561. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22562. private static _CleanMatricesWeights;
  22563. /**
  22564. * Create a new geometry from persisted data (Using .babylon file format)
  22565. * @param parsedVertexData defines the persisted data
  22566. * @param scene defines the hosting scene
  22567. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22568. * @returns the new geometry object
  22569. */
  22570. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22571. }
  22572. }
  22573. declare module BABYLON {
  22574. /**
  22575. * Define an interface for all classes that will get and set the data on vertices
  22576. */
  22577. export interface IGetSetVerticesData {
  22578. /**
  22579. * Gets a boolean indicating if specific vertex data is present
  22580. * @param kind defines the vertex data kind to use
  22581. * @returns true is data kind is present
  22582. */
  22583. isVerticesDataPresent(kind: string): boolean;
  22584. /**
  22585. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22586. * @param kind defines the data kind (Position, normal, etc...)
  22587. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22588. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22589. * @returns a float array containing vertex data
  22590. */
  22591. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22592. /**
  22593. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22594. * @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.
  22595. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22596. * @returns the indices array or an empty array if the mesh has no geometry
  22597. */
  22598. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22599. /**
  22600. * Set specific vertex data
  22601. * @param kind defines the data kind (Position, normal, etc...)
  22602. * @param data defines the vertex data to use
  22603. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22604. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22605. */
  22606. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22607. /**
  22608. * Update a specific associated vertex buffer
  22609. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22610. * - VertexBuffer.PositionKind
  22611. * - VertexBuffer.UVKind
  22612. * - VertexBuffer.UV2Kind
  22613. * - VertexBuffer.UV3Kind
  22614. * - VertexBuffer.UV4Kind
  22615. * - VertexBuffer.UV5Kind
  22616. * - VertexBuffer.UV6Kind
  22617. * - VertexBuffer.ColorKind
  22618. * - VertexBuffer.MatricesIndicesKind
  22619. * - VertexBuffer.MatricesIndicesExtraKind
  22620. * - VertexBuffer.MatricesWeightsKind
  22621. * - VertexBuffer.MatricesWeightsExtraKind
  22622. * @param data defines the data source
  22623. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22624. * @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)
  22625. */
  22626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22627. /**
  22628. * Creates a new index buffer
  22629. * @param indices defines the indices to store in the index buffer
  22630. * @param totalVertices defines the total number of vertices (could be null)
  22631. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22632. */
  22633. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22634. }
  22635. /**
  22636. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22637. */
  22638. export class VertexData {
  22639. /**
  22640. * Mesh side orientation : usually the external or front surface
  22641. */
  22642. static readonly FRONTSIDE: number;
  22643. /**
  22644. * Mesh side orientation : usually the internal or back surface
  22645. */
  22646. static readonly BACKSIDE: number;
  22647. /**
  22648. * Mesh side orientation : both internal and external or front and back surfaces
  22649. */
  22650. static readonly DOUBLESIDE: number;
  22651. /**
  22652. * Mesh side orientation : by default, `FRONTSIDE`
  22653. */
  22654. static readonly DEFAULTSIDE: number;
  22655. /**
  22656. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22657. */
  22658. positions: Nullable<FloatArray>;
  22659. /**
  22660. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22661. */
  22662. normals: Nullable<FloatArray>;
  22663. /**
  22664. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22665. */
  22666. tangents: Nullable<FloatArray>;
  22667. /**
  22668. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22669. */
  22670. uvs: Nullable<FloatArray>;
  22671. /**
  22672. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22673. */
  22674. uvs2: Nullable<FloatArray>;
  22675. /**
  22676. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22677. */
  22678. uvs3: Nullable<FloatArray>;
  22679. /**
  22680. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22681. */
  22682. uvs4: Nullable<FloatArray>;
  22683. /**
  22684. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22685. */
  22686. uvs5: Nullable<FloatArray>;
  22687. /**
  22688. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22689. */
  22690. uvs6: Nullable<FloatArray>;
  22691. /**
  22692. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22693. */
  22694. colors: Nullable<FloatArray>;
  22695. /**
  22696. * 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).
  22697. */
  22698. matricesIndices: Nullable<FloatArray>;
  22699. /**
  22700. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22701. */
  22702. matricesWeights: Nullable<FloatArray>;
  22703. /**
  22704. * An array extending the number of possible indices
  22705. */
  22706. matricesIndicesExtra: Nullable<FloatArray>;
  22707. /**
  22708. * An array extending the number of possible weights when the number of indices is extended
  22709. */
  22710. matricesWeightsExtra: Nullable<FloatArray>;
  22711. /**
  22712. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22713. */
  22714. indices: Nullable<IndicesArray>;
  22715. /**
  22716. * Uses the passed data array to set the set the values for the specified kind of data
  22717. * @param data a linear array of floating numbers
  22718. * @param kind the type of data that is being set, eg positions, colors etc
  22719. */
  22720. set(data: FloatArray, kind: string): void;
  22721. /**
  22722. * Associates the vertexData to the passed Mesh.
  22723. * Sets it as updatable or not (default `false`)
  22724. * @param mesh the mesh the vertexData is applied to
  22725. * @param updatable when used and having the value true allows new data to update the vertexData
  22726. * @returns the VertexData
  22727. */
  22728. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22729. /**
  22730. * Associates the vertexData to the passed Geometry.
  22731. * Sets it as updatable or not (default `false`)
  22732. * @param geometry the geometry the vertexData is applied to
  22733. * @param updatable when used and having the value true allows new data to update the vertexData
  22734. * @returns VertexData
  22735. */
  22736. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22737. /**
  22738. * Updates the associated mesh
  22739. * @param mesh the mesh to be updated
  22740. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22741. * @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
  22742. * @returns VertexData
  22743. */
  22744. updateMesh(mesh: Mesh): VertexData;
  22745. /**
  22746. * Updates the associated geometry
  22747. * @param geometry the geometry to be updated
  22748. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22749. * @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
  22750. * @returns VertexData.
  22751. */
  22752. updateGeometry(geometry: Geometry): VertexData;
  22753. private _applyTo;
  22754. private _update;
  22755. /**
  22756. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22757. * @param matrix the transforming matrix
  22758. * @returns the VertexData
  22759. */
  22760. transform(matrix: Matrix): VertexData;
  22761. /**
  22762. * Merges the passed VertexData into the current one
  22763. * @param other the VertexData to be merged into the current one
  22764. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22765. * @returns the modified VertexData
  22766. */
  22767. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22768. private _mergeElement;
  22769. private _validate;
  22770. /**
  22771. * Serializes the VertexData
  22772. * @returns a serialized object
  22773. */
  22774. serialize(): any;
  22775. /**
  22776. * Extracts the vertexData from a mesh
  22777. * @param mesh the mesh from which to extract the VertexData
  22778. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22779. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22780. * @returns the object VertexData associated to the passed mesh
  22781. */
  22782. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22783. /**
  22784. * Extracts the vertexData from the geometry
  22785. * @param geometry the geometry from which to extract the VertexData
  22786. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22787. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22788. * @returns the object VertexData associated to the passed mesh
  22789. */
  22790. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22791. private static _ExtractFrom;
  22792. /**
  22793. * Creates the VertexData for a Ribbon
  22794. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22795. * * pathArray array of paths, each of which an array of successive Vector3
  22796. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22797. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22798. * * 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
  22799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22800. * * 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)
  22801. * * 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)
  22802. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22803. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22804. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22805. * @returns the VertexData of the ribbon
  22806. */
  22807. static CreateRibbon(options: {
  22808. pathArray: Vector3[][];
  22809. closeArray?: boolean;
  22810. closePath?: boolean;
  22811. offset?: number;
  22812. sideOrientation?: number;
  22813. frontUVs?: Vector4;
  22814. backUVs?: Vector4;
  22815. invertUV?: boolean;
  22816. uvs?: Vector2[];
  22817. colors?: Color4[];
  22818. }): VertexData;
  22819. /**
  22820. * Creates the VertexData for a box
  22821. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22822. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22823. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22824. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22825. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22826. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22827. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22828. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22829. * * 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)
  22830. * * 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)
  22831. * @returns the VertexData of the box
  22832. */
  22833. static CreateBox(options: {
  22834. size?: number;
  22835. width?: number;
  22836. height?: number;
  22837. depth?: number;
  22838. faceUV?: Vector4[];
  22839. faceColors?: Color4[];
  22840. sideOrientation?: number;
  22841. frontUVs?: Vector4;
  22842. backUVs?: Vector4;
  22843. }): VertexData;
  22844. /**
  22845. * Creates the VertexData for a tiled box
  22846. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22847. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22848. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22849. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22851. * @returns the VertexData of the box
  22852. */
  22853. static CreateTiledBox(options: {
  22854. pattern?: number;
  22855. width?: number;
  22856. height?: number;
  22857. depth?: number;
  22858. tileSize?: number;
  22859. tileWidth?: number;
  22860. tileHeight?: number;
  22861. alignHorizontal?: number;
  22862. alignVertical?: number;
  22863. faceUV?: Vector4[];
  22864. faceColors?: Color4[];
  22865. sideOrientation?: number;
  22866. }): VertexData;
  22867. /**
  22868. * Creates the VertexData for a tiled plane
  22869. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22870. * * pattern a limited pattern arrangement depending on the number
  22871. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22872. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22873. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22874. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22875. * * 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)
  22876. * * 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)
  22877. * @returns the VertexData of the tiled plane
  22878. */
  22879. static CreateTiledPlane(options: {
  22880. pattern?: number;
  22881. tileSize?: number;
  22882. tileWidth?: number;
  22883. tileHeight?: number;
  22884. size?: number;
  22885. width?: number;
  22886. height?: number;
  22887. alignHorizontal?: number;
  22888. alignVertical?: number;
  22889. sideOrientation?: number;
  22890. frontUVs?: Vector4;
  22891. backUVs?: Vector4;
  22892. }): VertexData;
  22893. /**
  22894. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22895. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22896. * * segments sets the number of horizontal strips optional, default 32
  22897. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22898. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22899. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22900. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22901. * * 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
  22902. * * 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
  22903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22904. * * 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)
  22905. * * 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)
  22906. * @returns the VertexData of the ellipsoid
  22907. */
  22908. static CreateSphere(options: {
  22909. segments?: number;
  22910. diameter?: number;
  22911. diameterX?: number;
  22912. diameterY?: number;
  22913. diameterZ?: number;
  22914. arc?: number;
  22915. slice?: number;
  22916. sideOrientation?: number;
  22917. frontUVs?: Vector4;
  22918. backUVs?: Vector4;
  22919. }): VertexData;
  22920. /**
  22921. * Creates the VertexData for a cylinder, cone or prism
  22922. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22923. * * height sets the height (y direction) of the cylinder, optional, default 2
  22924. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22925. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22926. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22927. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22928. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22929. * * 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
  22930. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22931. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22932. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22933. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22934. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22935. * * 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)
  22936. * * 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)
  22937. * @returns the VertexData of the cylinder, cone or prism
  22938. */
  22939. static CreateCylinder(options: {
  22940. height?: number;
  22941. diameterTop?: number;
  22942. diameterBottom?: number;
  22943. diameter?: number;
  22944. tessellation?: number;
  22945. subdivisions?: number;
  22946. arc?: number;
  22947. faceColors?: Color4[];
  22948. faceUV?: Vector4[];
  22949. hasRings?: boolean;
  22950. enclose?: boolean;
  22951. sideOrientation?: number;
  22952. frontUVs?: Vector4;
  22953. backUVs?: Vector4;
  22954. }): VertexData;
  22955. /**
  22956. * Creates the VertexData for a torus
  22957. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22958. * * diameter the diameter of the torus, optional default 1
  22959. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22960. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22962. * * 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)
  22963. * * 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)
  22964. * @returns the VertexData of the torus
  22965. */
  22966. static CreateTorus(options: {
  22967. diameter?: number;
  22968. thickness?: number;
  22969. tessellation?: number;
  22970. sideOrientation?: number;
  22971. frontUVs?: Vector4;
  22972. backUVs?: Vector4;
  22973. }): VertexData;
  22974. /**
  22975. * Creates the VertexData of the LineSystem
  22976. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22977. * - lines an array of lines, each line being an array of successive Vector3
  22978. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22979. * @returns the VertexData of the LineSystem
  22980. */
  22981. static CreateLineSystem(options: {
  22982. lines: Vector3[][];
  22983. colors?: Nullable<Color4[][]>;
  22984. }): VertexData;
  22985. /**
  22986. * Create the VertexData for a DashedLines
  22987. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22988. * - points an array successive Vector3
  22989. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22990. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22991. * - dashNb the intended total number of dashes, optional, default 200
  22992. * @returns the VertexData for the DashedLines
  22993. */
  22994. static CreateDashedLines(options: {
  22995. points: Vector3[];
  22996. dashSize?: number;
  22997. gapSize?: number;
  22998. dashNb?: number;
  22999. }): VertexData;
  23000. /**
  23001. * Creates the VertexData for a Ground
  23002. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23003. * - width the width (x direction) of the ground, optional, default 1
  23004. * - height the height (z direction) of the ground, optional, default 1
  23005. * - subdivisions the number of subdivisions per side, optional, default 1
  23006. * @returns the VertexData of the Ground
  23007. */
  23008. static CreateGround(options: {
  23009. width?: number;
  23010. height?: number;
  23011. subdivisions?: number;
  23012. subdivisionsX?: number;
  23013. subdivisionsY?: number;
  23014. }): VertexData;
  23015. /**
  23016. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23017. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23018. * * xmin the ground minimum X coordinate, optional, default -1
  23019. * * zmin the ground minimum Z coordinate, optional, default -1
  23020. * * xmax the ground maximum X coordinate, optional, default 1
  23021. * * zmax the ground maximum Z coordinate, optional, default 1
  23022. * * 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}
  23023. * * 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}
  23024. * @returns the VertexData of the TiledGround
  23025. */
  23026. static CreateTiledGround(options: {
  23027. xmin: number;
  23028. zmin: number;
  23029. xmax: number;
  23030. zmax: number;
  23031. subdivisions?: {
  23032. w: number;
  23033. h: number;
  23034. };
  23035. precision?: {
  23036. w: number;
  23037. h: number;
  23038. };
  23039. }): VertexData;
  23040. /**
  23041. * Creates the VertexData of the Ground designed from a heightmap
  23042. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23043. * * width the width (x direction) of the ground
  23044. * * height the height (z direction) of the ground
  23045. * * subdivisions the number of subdivisions per side
  23046. * * minHeight the minimum altitude on the ground, optional, default 0
  23047. * * maxHeight the maximum altitude on the ground, optional default 1
  23048. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23049. * * buffer the array holding the image color data
  23050. * * bufferWidth the width of image
  23051. * * bufferHeight the height of image
  23052. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23053. * @returns the VertexData of the Ground designed from a heightmap
  23054. */
  23055. static CreateGroundFromHeightMap(options: {
  23056. width: number;
  23057. height: number;
  23058. subdivisions: number;
  23059. minHeight: number;
  23060. maxHeight: number;
  23061. colorFilter: Color3;
  23062. buffer: Uint8Array;
  23063. bufferWidth: number;
  23064. bufferHeight: number;
  23065. alphaFilter: number;
  23066. }): VertexData;
  23067. /**
  23068. * Creates the VertexData for a Plane
  23069. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23070. * * size sets the width and height of the plane to the value of size, optional default 1
  23071. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23072. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23073. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23074. * * 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)
  23075. * * 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)
  23076. * @returns the VertexData of the box
  23077. */
  23078. static CreatePlane(options: {
  23079. size?: number;
  23080. width?: number;
  23081. height?: number;
  23082. sideOrientation?: number;
  23083. frontUVs?: Vector4;
  23084. backUVs?: Vector4;
  23085. }): VertexData;
  23086. /**
  23087. * Creates the VertexData of the Disc or regular Polygon
  23088. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23089. * * radius the radius of the disc, optional default 0.5
  23090. * * tessellation the number of polygon sides, optional, default 64
  23091. * * 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
  23092. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23093. * * 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)
  23094. * * 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)
  23095. * @returns the VertexData of the box
  23096. */
  23097. static CreateDisc(options: {
  23098. radius?: number;
  23099. tessellation?: number;
  23100. arc?: number;
  23101. sideOrientation?: number;
  23102. frontUVs?: Vector4;
  23103. backUVs?: Vector4;
  23104. }): VertexData;
  23105. /**
  23106. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23107. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23108. * @param polygon a mesh built from polygonTriangulation.build()
  23109. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23110. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23111. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23112. * @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)
  23113. * @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)
  23114. * @returns the VertexData of the Polygon
  23115. */
  23116. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23117. /**
  23118. * Creates the VertexData of the IcoSphere
  23119. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23120. * * radius the radius of the IcoSphere, optional default 1
  23121. * * radiusX allows stretching in the x direction, optional, default radius
  23122. * * radiusY allows stretching in the y direction, optional, default radius
  23123. * * radiusZ allows stretching in the z direction, optional, default radius
  23124. * * flat when true creates a flat shaded mesh, optional, default true
  23125. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23126. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23127. * * 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)
  23128. * * 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)
  23129. * @returns the VertexData of the IcoSphere
  23130. */
  23131. static CreateIcoSphere(options: {
  23132. radius?: number;
  23133. radiusX?: number;
  23134. radiusY?: number;
  23135. radiusZ?: number;
  23136. flat?: boolean;
  23137. subdivisions?: number;
  23138. sideOrientation?: number;
  23139. frontUVs?: Vector4;
  23140. backUVs?: Vector4;
  23141. }): VertexData;
  23142. /**
  23143. * Creates the VertexData for a Polyhedron
  23144. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23145. * * type provided types are:
  23146. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23147. * * 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)
  23148. * * size the size of the IcoSphere, optional default 1
  23149. * * sizeX allows stretching in the x direction, optional, default size
  23150. * * sizeY allows stretching in the y direction, optional, default size
  23151. * * sizeZ allows stretching in the z direction, optional, default size
  23152. * * 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
  23153. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23154. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23155. * * flat when true creates a flat shaded mesh, optional, default true
  23156. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23158. * * 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)
  23159. * * 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)
  23160. * @returns the VertexData of the Polyhedron
  23161. */
  23162. static CreatePolyhedron(options: {
  23163. type?: number;
  23164. size?: number;
  23165. sizeX?: number;
  23166. sizeY?: number;
  23167. sizeZ?: number;
  23168. custom?: any;
  23169. faceUV?: Vector4[];
  23170. faceColors?: Color4[];
  23171. flat?: boolean;
  23172. sideOrientation?: number;
  23173. frontUVs?: Vector4;
  23174. backUVs?: Vector4;
  23175. }): VertexData;
  23176. /**
  23177. * Creates the VertexData for a TorusKnot
  23178. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23179. * * radius the radius of the torus knot, optional, default 2
  23180. * * tube the thickness of the tube, optional, default 0.5
  23181. * * radialSegments the number of sides on each tube segments, optional, default 32
  23182. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23183. * * p the number of windings around the z axis, optional, default 2
  23184. * * q the number of windings around the x axis, optional, default 3
  23185. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23186. * * 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)
  23187. * * 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)
  23188. * @returns the VertexData of the Torus Knot
  23189. */
  23190. static CreateTorusKnot(options: {
  23191. radius?: number;
  23192. tube?: number;
  23193. radialSegments?: number;
  23194. tubularSegments?: number;
  23195. p?: number;
  23196. q?: number;
  23197. sideOrientation?: number;
  23198. frontUVs?: Vector4;
  23199. backUVs?: Vector4;
  23200. }): VertexData;
  23201. /**
  23202. * Compute normals for given positions and indices
  23203. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23204. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23205. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23206. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23207. * * facetNormals : optional array of facet normals (vector3)
  23208. * * facetPositions : optional array of facet positions (vector3)
  23209. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23210. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23211. * * bInfo : optional bounding info, required for facetPartitioning computation
  23212. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23213. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23214. * * useRightHandedSystem: optional boolean to for right handed system computation
  23215. * * depthSort : optional boolean to enable the facet depth sort computation
  23216. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23217. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23218. */
  23219. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23220. facetNormals?: any;
  23221. facetPositions?: any;
  23222. facetPartitioning?: any;
  23223. ratio?: number;
  23224. bInfo?: any;
  23225. bbSize?: Vector3;
  23226. subDiv?: any;
  23227. useRightHandedSystem?: boolean;
  23228. depthSort?: boolean;
  23229. distanceTo?: Vector3;
  23230. depthSortedFacets?: any;
  23231. }): void;
  23232. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23233. /**
  23234. * Applies VertexData created from the imported parameters to the geometry
  23235. * @param parsedVertexData the parsed data from an imported file
  23236. * @param geometry the geometry to apply the VertexData to
  23237. */
  23238. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23239. }
  23240. }
  23241. declare module BABYLON {
  23242. /**
  23243. * Class containing static functions to help procedurally build meshes
  23244. */
  23245. export class DiscBuilder {
  23246. /**
  23247. * Creates a plane polygonal mesh. By default, this is a disc
  23248. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23249. * * 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
  23250. * * 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
  23251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  23252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  23253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23254. * @param name defines the name of the mesh
  23255. * @param options defines the options used to create the mesh
  23256. * @param scene defines the hosting scene
  23257. * @returns the plane polygonal mesh
  23258. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  23259. */
  23260. static CreateDisc(name: string, options: {
  23261. radius?: number;
  23262. tessellation?: number;
  23263. arc?: number;
  23264. updatable?: boolean;
  23265. sideOrientation?: number;
  23266. frontUVs?: Vector4;
  23267. backUVs?: Vector4;
  23268. }, scene?: Nullable<Scene>): Mesh;
  23269. }
  23270. }
  23271. declare module BABYLON {
  23272. /**
  23273. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  23274. *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.
  23275. * The SPS is also a particle system. It provides some methods to manage the particles.
  23276. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  23277. *
  23278. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  23279. */
  23280. export class SolidParticleSystem implements IDisposable {
  23281. /**
  23282. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  23283. * Example : var p = SPS.particles[i];
  23284. */
  23285. particles: SolidParticle[];
  23286. /**
  23287. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  23288. */
  23289. nbParticles: number;
  23290. /**
  23291. * If the particles must ever face the camera (default false). Useful for planar particles.
  23292. */
  23293. billboard: boolean;
  23294. /**
  23295. * Recompute normals when adding a shape
  23296. */
  23297. recomputeNormals: boolean;
  23298. /**
  23299. * This a counter ofr your own usage. It's not set by any SPS functions.
  23300. */
  23301. counter: number;
  23302. /**
  23303. * The SPS name. This name is also given to the underlying mesh.
  23304. */
  23305. name: string;
  23306. /**
  23307. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  23308. */
  23309. mesh: Mesh;
  23310. /**
  23311. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  23312. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  23313. */
  23314. vars: any;
  23315. /**
  23316. * This array is populated when the SPS is set as 'pickable'.
  23317. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  23318. * Each element of this array is an object `{idx: int, faceId: int}`.
  23319. * `idx` is the picked particle index in the `SPS.particles` array
  23320. * `faceId` is the picked face index counted within this particle.
  23321. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  23322. */
  23323. pickedParticles: {
  23324. idx: number;
  23325. faceId: number;
  23326. }[];
  23327. /**
  23328. * This array is populated when `enableDepthSort` is set to true.
  23329. * Each element of this array is an instance of the class DepthSortedParticle.
  23330. */
  23331. depthSortedParticles: DepthSortedParticle[];
  23332. /**
  23333. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  23334. * @hidden
  23335. */ private _bSphereOnly: boolean;
  23336. /**
  23337. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  23338. * @hidden
  23339. */ private _bSphereRadiusFactor: number;
  23340. private _scene;
  23341. private _positions;
  23342. private _indices;
  23343. private _normals;
  23344. private _colors;
  23345. private _uvs;
  23346. private _indices32;
  23347. private _positions32;
  23348. private _normals32;
  23349. private _fixedNormal32;
  23350. private _colors32;
  23351. private _uvs32;
  23352. private _index;
  23353. private _updatable;
  23354. private _pickable;
  23355. private _isVisibilityBoxLocked;
  23356. private _alwaysVisible;
  23357. private _depthSort;
  23358. private _shapeCounter;
  23359. private _copy;
  23360. private _color;
  23361. private _computeParticleColor;
  23362. private _computeParticleTexture;
  23363. private _computeParticleRotation;
  23364. private _computeParticleVertex;
  23365. private _computeBoundingBox;
  23366. private _depthSortParticles;
  23367. private _camera;
  23368. private _mustUnrotateFixedNormals;
  23369. private _particlesIntersect;
  23370. private _needs32Bits;
  23371. /**
  23372. * Creates a SPS (Solid Particle System) object.
  23373. * @param name (String) is the SPS name, this will be the underlying mesh name.
  23374. * @param scene (Scene) is the scene in which the SPS is added.
  23375. * @param options defines the options of the sps e.g.
  23376. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  23377. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  23378. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  23379. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  23380. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  23381. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  23382. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  23383. */
  23384. constructor(name: string, scene: Scene, options?: {
  23385. updatable?: boolean;
  23386. isPickable?: boolean;
  23387. enableDepthSort?: boolean;
  23388. particleIntersection?: boolean;
  23389. boundingSphereOnly?: boolean;
  23390. bSphereRadiusFactor?: number;
  23391. });
  23392. /**
  23393. * Builds the SPS underlying mesh. Returns a standard Mesh.
  23394. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  23395. * @returns the created mesh
  23396. */
  23397. buildMesh(): Mesh;
  23398. /**
  23399. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  23400. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  23401. * Thus the particles generated from `digest()` have their property `position` set yet.
  23402. * @param mesh ( Mesh ) is the mesh to be digested
  23403. * @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
  23404. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  23405. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  23406. * @returns the current SPS
  23407. */
  23408. digest(mesh: Mesh, options?: {
  23409. facetNb?: number;
  23410. number?: number;
  23411. delta?: number;
  23412. }): SolidParticleSystem;
  23413. private _unrotateFixedNormals;
  23414. private _resetCopy;
  23415. private _meshBuilder;
  23416. private _posToShape;
  23417. private _uvsToShapeUV;
  23418. private _addParticle;
  23419. /**
  23420. * Adds some particles to the SPS from the model shape. Returns the shape id.
  23421. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  23422. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  23423. * @param nb (positive integer) the number of particles to be created from this model
  23424. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  23425. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  23426. * @returns the number of shapes in the system
  23427. */
  23428. addShape(mesh: Mesh, nb: number, options?: {
  23429. positionFunction?: any;
  23430. vertexFunction?: any;
  23431. }): number;
  23432. private _rebuildParticle;
  23433. /**
  23434. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  23435. * @returns the SPS.
  23436. */
  23437. rebuildMesh(): SolidParticleSystem;
  23438. /**
  23439. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  23440. * This method calls `updateParticle()` for each particle of the SPS.
  23441. * For an animated SPS, it is usually called within the render loop.
  23442. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  23443. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  23444. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  23445. * @returns the SPS.
  23446. */
  23447. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  23448. /**
  23449. * Disposes the SPS.
  23450. */
  23451. dispose(): void;
  23452. /**
  23453. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  23454. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23455. * @returns the SPS.
  23456. */
  23457. refreshVisibleSize(): SolidParticleSystem;
  23458. /**
  23459. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  23460. * @param size the size (float) of the visibility box
  23461. * note : this doesn't lock the SPS mesh bounding box.
  23462. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23463. */
  23464. setVisibilityBox(size: number): void;
  23465. /**
  23466. * Gets whether the SPS as always visible or not
  23467. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23468. */
  23469. /**
  23470. * Sets the SPS as always visible or not
  23471. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23472. */
  23473. isAlwaysVisible: boolean;
  23474. /**
  23475. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23476. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23477. */
  23478. /**
  23479. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  23480. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  23481. */
  23482. isVisibilityBoxLocked: boolean;
  23483. /**
  23484. * Tells to `setParticles()` to compute the particle rotations or not.
  23485. * Default value : true. The SPS is faster when it's set to false.
  23486. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23487. */
  23488. /**
  23489. * Gets if `setParticles()` computes the particle rotations or not.
  23490. * Default value : true. The SPS is faster when it's set to false.
  23491. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  23492. */
  23493. computeParticleRotation: boolean;
  23494. /**
  23495. * Tells to `setParticles()` to compute the particle colors or not.
  23496. * Default value : true. The SPS is faster when it's set to false.
  23497. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23498. */
  23499. /**
  23500. * Gets if `setParticles()` computes the particle colors or not.
  23501. * Default value : true. The SPS is faster when it's set to false.
  23502. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  23503. */
  23504. computeParticleColor: boolean;
  23505. /**
  23506. * Gets if `setParticles()` computes the particle textures or not.
  23507. * Default value : true. The SPS is faster when it's set to false.
  23508. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  23509. */
  23510. computeParticleTexture: boolean;
  23511. /**
  23512. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  23513. * Default value : false. The SPS is faster when it's set to false.
  23514. * Note : the particle custom vertex positions aren't stored values.
  23515. */
  23516. /**
  23517. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  23518. * Default value : false. The SPS is faster when it's set to false.
  23519. * Note : the particle custom vertex positions aren't stored values.
  23520. */
  23521. computeParticleVertex: boolean;
  23522. /**
  23523. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  23524. */
  23525. /**
  23526. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  23527. */
  23528. computeBoundingBox: boolean;
  23529. /**
  23530. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  23531. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23532. * Default : `true`
  23533. */
  23534. /**
  23535. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  23536. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  23537. * Default : `true`
  23538. */
  23539. depthSortParticles: boolean;
  23540. /**
  23541. * This function does nothing. It may be overwritten to set all the particle first values.
  23542. * The SPS doesn't call this function, you may have to call it by your own.
  23543. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23544. */
  23545. initParticles(): void;
  23546. /**
  23547. * This function does nothing. It may be overwritten to recycle a particle.
  23548. * The SPS doesn't call this function, you may have to call it by your own.
  23549. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23550. * @param particle The particle to recycle
  23551. * @returns the recycled particle
  23552. */
  23553. recycleParticle(particle: SolidParticle): SolidParticle;
  23554. /**
  23555. * Updates a particle : this function should be overwritten by the user.
  23556. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  23557. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  23558. * @example : just set a particle position or velocity and recycle conditions
  23559. * @param particle The particle to update
  23560. * @returns the updated particle
  23561. */
  23562. updateParticle(particle: SolidParticle): SolidParticle;
  23563. /**
  23564. * Updates a vertex of a particle : it can be overwritten by the user.
  23565. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  23566. * @param particle the current particle
  23567. * @param vertex the current index of the current particle
  23568. * @param pt the index of the current vertex in the particle shape
  23569. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  23570. * @example : just set a vertex particle position
  23571. * @returns the updated vertex
  23572. */
  23573. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  23574. /**
  23575. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  23576. * This does nothing and may be overwritten by the user.
  23577. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23578. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23579. * @param update the boolean update value actually passed to setParticles()
  23580. */
  23581. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23582. /**
  23583. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  23584. * This will be passed three parameters.
  23585. * This does nothing and may be overwritten by the user.
  23586. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23587. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  23588. * @param update the boolean update value actually passed to setParticles()
  23589. */
  23590. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  23591. }
  23592. }
  23593. declare module BABYLON {
  23594. /**
  23595. * Represents one particle of a solid particle system.
  23596. */
  23597. export class SolidParticle {
  23598. /**
  23599. * particle global index
  23600. */
  23601. idx: number;
  23602. /**
  23603. * The color of the particle
  23604. */
  23605. color: Nullable<Color4>;
  23606. /**
  23607. * The world space position of the particle.
  23608. */
  23609. position: Vector3;
  23610. /**
  23611. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  23612. */
  23613. rotation: Vector3;
  23614. /**
  23615. * The world space rotation quaternion of the particle.
  23616. */
  23617. rotationQuaternion: Nullable<Quaternion>;
  23618. /**
  23619. * The scaling of the particle.
  23620. */
  23621. scaling: Vector3;
  23622. /**
  23623. * The uvs of the particle.
  23624. */
  23625. uvs: Vector4;
  23626. /**
  23627. * The current speed of the particle.
  23628. */
  23629. velocity: Vector3;
  23630. /**
  23631. * The pivot point in the particle local space.
  23632. */
  23633. pivot: Vector3;
  23634. /**
  23635. * Must the particle be translated from its pivot point in its local space ?
  23636. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  23637. * Default : false
  23638. */
  23639. translateFromPivot: boolean;
  23640. /**
  23641. * Is the particle active or not ?
  23642. */
  23643. alive: boolean;
  23644. /**
  23645. * Is the particle visible or not ?
  23646. */
  23647. isVisible: boolean;
  23648. /**
  23649. * Index of this particle in the global "positions" array (Internal use)
  23650. * @hidden
  23651. */ private _pos: number;
  23652. /**
  23653. * @hidden Index of this particle in the global "indices" array (Internal use)
  23654. */ private _ind: number;
  23655. /**
  23656. * @hidden ModelShape of this particle (Internal use)
  23657. */ private _model: ModelShape;
  23658. /**
  23659. * ModelShape id of this particle
  23660. */
  23661. shapeId: number;
  23662. /**
  23663. * Index of the particle in its shape id (Internal use)
  23664. */
  23665. idxInShape: number;
  23666. /**
  23667. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  23668. */ private _modelBoundingInfo: BoundingInfo;
  23669. /**
  23670. * @hidden Particle BoundingInfo object (Internal use)
  23671. */ private _boundingInfo: BoundingInfo;
  23672. /**
  23673. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  23674. */ private _sps: SolidParticleSystem;
  23675. /**
  23676. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  23677. */ private _stillInvisible: boolean;
  23678. /**
  23679. * @hidden Last computed particle rotation matrix
  23680. */ private _rotationMatrix: number[];
  23681. /**
  23682. * Parent particle Id, if any.
  23683. * Default null.
  23684. */
  23685. parentId: Nullable<number>;
  23686. /**
  23687. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  23688. * The possible values are :
  23689. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23690. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23691. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23692. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23693. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23694. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  23695. * */
  23696. cullingStrategy: number;
  23697. /**
  23698. * @hidden Internal global position in the SPS.
  23699. */ private _globalPosition: Vector3;
  23700. /**
  23701. * Creates a Solid Particle object.
  23702. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  23703. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  23704. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  23705. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  23706. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  23707. * @param shapeId (integer) is the model shape identifier in the SPS.
  23708. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  23709. * @param sps defines the sps it is associated to
  23710. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  23711. */
  23712. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  23713. /**
  23714. * Legacy support, changed scale to scaling
  23715. */
  23716. /**
  23717. * Legacy support, changed scale to scaling
  23718. */
  23719. scale: Vector3;
  23720. /**
  23721. * Legacy support, changed quaternion to rotationQuaternion
  23722. */
  23723. /**
  23724. * Legacy support, changed quaternion to rotationQuaternion
  23725. */
  23726. quaternion: Nullable<Quaternion>;
  23727. /**
  23728. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  23729. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  23730. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  23731. * @returns true if it intersects
  23732. */
  23733. intersectsMesh(target: Mesh | SolidParticle): boolean;
  23734. /**
  23735. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  23736. * A particle is in the frustum if its bounding box intersects the frustum
  23737. * @param frustumPlanes defines the frustum to test
  23738. * @returns true if the particle is in the frustum planes
  23739. */
  23740. isInFrustum(frustumPlanes: Plane[]): boolean;
  23741. /**
  23742. * get the rotation matrix of the particle
  23743. * @hidden
  23744. */
  23745. getRotationMatrix(m: Matrix): void;
  23746. }
  23747. /**
  23748. * Represents the shape of the model used by one particle of a solid particle system.
  23749. * SPS internal tool, don't use it manually.
  23750. */
  23751. export class ModelShape {
  23752. /**
  23753. * The shape id
  23754. * @hidden
  23755. */
  23756. shapeID: number;
  23757. /**
  23758. * flat array of model positions (internal use)
  23759. * @hidden
  23760. */ private _shape: Vector3[];
  23761. /**
  23762. * flat array of model UVs (internal use)
  23763. * @hidden
  23764. */ private _shapeUV: number[];
  23765. /**
  23766. * length of the shape in the model indices array (internal use)
  23767. * @hidden
  23768. */ private _indicesLength: number;
  23769. /**
  23770. * Custom position function (internal use)
  23771. * @hidden
  23772. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  23773. /**
  23774. * Custom vertex function (internal use)
  23775. * @hidden
  23776. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  23777. /**
  23778. * 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.
  23779. * SPS internal tool, don't use it manually.
  23780. * @hidden
  23781. */
  23782. 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>);
  23783. }
  23784. /**
  23785. * Represents a Depth Sorted Particle in the solid particle system.
  23786. */
  23787. export class DepthSortedParticle {
  23788. /**
  23789. * Index of the particle in the "indices" array
  23790. */
  23791. ind: number;
  23792. /**
  23793. * Length of the particle shape in the "indices" array
  23794. */
  23795. indicesLength: number;
  23796. /**
  23797. * Squared distance from the particle to the camera
  23798. */
  23799. sqDistance: number;
  23800. }
  23801. }
  23802. declare module BABYLON {
  23803. /**
  23804. * @hidden
  23805. */
  23806. export class _MeshCollisionData { private _checkCollisions: boolean; private _collisionMask: number; private _collisionGroup: number; private _collider: Nullable<Collider>; private _oldPositionForCollisions: Vector3; private _diffPositionForCollisions: Vector3; private _onCollideObserver: Nullable<Observer<AbstractMesh>>; private _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  23807. }
  23808. }
  23809. declare module BABYLON {
  23810. /** @hidden */ private class _FacetDataStorage {
  23811. facetPositions: Vector3[];
  23812. facetNormals: Vector3[];
  23813. facetPartitioning: number[][];
  23814. facetNb: number;
  23815. partitioningSubdivisions: number;
  23816. partitioningBBoxRatio: number;
  23817. facetDataEnabled: boolean;
  23818. facetParameters: any;
  23819. bbSize: Vector3;
  23820. subDiv: {
  23821. max: number;
  23822. X: number;
  23823. Y: number;
  23824. Z: number;
  23825. };
  23826. facetDepthSort: boolean;
  23827. facetDepthSortEnabled: boolean;
  23828. depthSortedIndices: IndicesArray;
  23829. depthSortedFacets: {
  23830. ind: number;
  23831. sqDistance: number;
  23832. }[];
  23833. facetDepthSortFunction: (f1: {
  23834. ind: number;
  23835. sqDistance: number;
  23836. }, f2: {
  23837. ind: number;
  23838. sqDistance: number;
  23839. }) => number;
  23840. facetDepthSortFrom: Vector3;
  23841. facetDepthSortOrigin: Vector3;
  23842. invertedMatrix: Matrix;
  23843. }
  23844. /**
  23845. * @hidden
  23846. **/ private class _InternalAbstractMeshDataInfo { private _hasVertexAlpha: boolean; private _useVertexColors: boolean; private _numBoneInfluencers: number; private _applyFog: boolean; private _receiveShadows: boolean; private _facetData: _FacetDataStorage; private _visibility: number; private _skeleton: Nullable<Skeleton>; private _layerMask: number; private _computeBonesUsingShaders: boolean; private _isActive: boolean; private _onlyForInstances: boolean; private _isActiveIntermediate: boolean; private _onlyForInstancesIntermediate: boolean;
  23847. }
  23848. /**
  23849. * Class used to store all common mesh properties
  23850. */
  23851. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  23852. /** No occlusion */
  23853. static OCCLUSION_TYPE_NONE: number;
  23854. /** Occlusion set to optimisitic */
  23855. static OCCLUSION_TYPE_OPTIMISTIC: number;
  23856. /** Occlusion set to strict */
  23857. static OCCLUSION_TYPE_STRICT: number;
  23858. /** Use an accurante occlusion algorithm */
  23859. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  23860. /** Use a conservative occlusion algorithm */
  23861. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  23862. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  23863. * Test order :
  23864. * Is the bounding sphere outside the frustum ?
  23865. * If not, are the bounding box vertices outside the frustum ?
  23866. * It not, then the cullable object is in the frustum.
  23867. */
  23868. static readonly CULLINGSTRATEGY_STANDARD: number;
  23869. /** Culling strategy : Bounding Sphere Only.
  23870. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  23871. * It's also less accurate than the standard because some not visible objects can still be selected.
  23872. * Test : is the bounding sphere outside the frustum ?
  23873. * If not, then the cullable object is in the frustum.
  23874. */
  23875. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  23876. /** Culling strategy : Optimistic Inclusion.
  23877. * This in an inclusion test first, then the standard exclusion test.
  23878. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  23879. * 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.
  23880. * Anyway, it's as accurate as the standard strategy.
  23881. * Test :
  23882. * Is the cullable object bounding sphere center in the frustum ?
  23883. * If not, apply the default culling strategy.
  23884. */
  23885. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  23886. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  23887. * This in an inclusion test first, then the bounding sphere only exclusion test.
  23888. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  23889. * 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.
  23890. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  23891. * Test :
  23892. * Is the cullable object bounding sphere center in the frustum ?
  23893. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  23894. */
  23895. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  23896. /**
  23897. * No billboard
  23898. */
  23899. static readonly BILLBOARDMODE_NONE: number;
  23900. /** Billboard on X axis */
  23901. static readonly BILLBOARDMODE_X: number;
  23902. /** Billboard on Y axis */
  23903. static readonly BILLBOARDMODE_Y: number;
  23904. /** Billboard on Z axis */
  23905. static readonly BILLBOARDMODE_Z: number;
  23906. /** Billboard on all axes */
  23907. static readonly BILLBOARDMODE_ALL: number;
  23908. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  23909. /**
  23910. * The culling strategy to use to check whether the mesh must be rendered or not.
  23911. * This value can be changed at any time and will be used on the next render mesh selection.
  23912. * The possible values are :
  23913. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  23914. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  23915. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  23916. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  23917. * Please read each static variable documentation to get details about the culling process.
  23918. * */
  23919. cullingStrategy: number;
  23920. /**
  23921. * Gets the number of facets in the mesh
  23922. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23923. */
  23924. readonly facetNb: number;
  23925. /**
  23926. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  23927. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23928. */
  23929. partitioningSubdivisions: number;
  23930. /**
  23931. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  23932. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  23933. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  23934. */
  23935. partitioningBBoxRatio: number;
  23936. /**
  23937. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  23938. * Works only for updatable meshes.
  23939. * Doesn't work with multi-materials
  23940. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23941. */
  23942. mustDepthSortFacets: boolean;
  23943. /**
  23944. * The location (Vector3) where the facet depth sort must be computed from.
  23945. * By default, the active camera position.
  23946. * Used only when facet depth sort is enabled
  23947. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  23948. */
  23949. facetDepthSortFrom: Vector3;
  23950. /**
  23951. * gets a boolean indicating if facetData is enabled
  23952. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  23953. */
  23954. readonly isFacetDataEnabled: boolean;
  23955. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  23956. /**
  23957. * An event triggered when this mesh collides with another one
  23958. */
  23959. onCollideObservable: Observable<AbstractMesh>;
  23960. /** Set a function to call when this mesh collides with another one */
  23961. onCollide: () => void;
  23962. /**
  23963. * An event triggered when the collision's position changes
  23964. */
  23965. onCollisionPositionChangeObservable: Observable<Vector3>;
  23966. /** Set a function to call when the collision's position changes */
  23967. onCollisionPositionChange: () => void;
  23968. /**
  23969. * An event triggered when material is changed
  23970. */
  23971. onMaterialChangedObservable: Observable<AbstractMesh>;
  23972. /**
  23973. * Gets or sets the orientation for POV movement & rotation
  23974. */
  23975. definedFacingForward: boolean;
  23976. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  23977. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  23978. /**
  23979. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23980. */
  23981. /**
  23982. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  23983. */
  23984. visibility: number;
  23985. /** Gets or sets the alpha index used to sort transparent meshes
  23986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  23987. */
  23988. alphaIndex: number;
  23989. /**
  23990. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  23991. */
  23992. isVisible: boolean;
  23993. /**
  23994. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  23995. */
  23996. isPickable: boolean;
  23997. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  23998. showSubMeshesBoundingBox: boolean;
  23999. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24000. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24001. */
  24002. isBlocker: boolean;
  24003. /**
  24004. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24005. */
  24006. enablePointerMoveEvents: boolean;
  24007. /**
  24008. * Specifies the rendering group id for this mesh (0 by default)
  24009. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24010. */
  24011. renderingGroupId: number;
  24012. private _material;
  24013. /** Gets or sets current material */
  24014. material: Nullable<Material>;
  24015. /**
  24016. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24017. * @see http://doc.babylonjs.com/babylon101/shadows
  24018. */
  24019. receiveShadows: boolean;
  24020. /** Defines color to use when rendering outline */
  24021. outlineColor: Color3;
  24022. /** Define width to use when rendering outline */
  24023. outlineWidth: number;
  24024. /** Defines color to use when rendering overlay */
  24025. overlayColor: Color3;
  24026. /** Defines alpha to use when rendering overlay */
  24027. overlayAlpha: number;
  24028. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24029. hasVertexAlpha: boolean;
  24030. /** 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) */
  24031. useVertexColors: boolean;
  24032. /**
  24033. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24034. */
  24035. computeBonesUsingShaders: boolean;
  24036. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24037. numBoneInfluencers: number;
  24038. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24039. applyFog: boolean;
  24040. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24041. useOctreeForRenderingSelection: boolean;
  24042. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24043. useOctreeForPicking: boolean;
  24044. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24045. useOctreeForCollisions: boolean;
  24046. /**
  24047. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24048. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24049. */
  24050. layerMask: number;
  24051. /**
  24052. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24053. */
  24054. alwaysSelectAsActiveMesh: boolean;
  24055. /**
  24056. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24057. */
  24058. doNotSyncBoundingInfo: boolean;
  24059. /**
  24060. * Gets or sets the current action manager
  24061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24062. */
  24063. actionManager: Nullable<AbstractActionManager>;
  24064. private _meshCollisionData;
  24065. /**
  24066. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24067. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24068. */
  24069. ellipsoid: Vector3;
  24070. /**
  24071. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24072. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24073. */
  24074. ellipsoidOffset: Vector3;
  24075. /**
  24076. * Gets or sets a collision mask used to mask collisions (default is -1).
  24077. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24078. */
  24079. collisionMask: number;
  24080. /**
  24081. * Gets or sets the current collision group mask (-1 by default).
  24082. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24083. */
  24084. collisionGroup: number;
  24085. /**
  24086. * Defines edge width used when edgesRenderer is enabled
  24087. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24088. */
  24089. edgesWidth: number;
  24090. /**
  24091. * Defines edge color used when edgesRenderer is enabled
  24092. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24093. */
  24094. edgesColor: Color4;
  24095. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  24096. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  24097. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  24098. /** @hidden */ private _renderId: number;
  24099. /**
  24100. * Gets or sets the list of subMeshes
  24101. * @see http://doc.babylonjs.com/how_to/multi_materials
  24102. */
  24103. subMeshes: SubMesh[];
  24104. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  24105. /** @hidden */ private _unIndexed: boolean;
  24106. /** @hidden */ private _lightSources: Light[];
  24107. /** Gets the list of lights affecting that mesh */
  24108. readonly lightSources: Light[];
  24109. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  24110. /** @hidden */ private _waitingData: {
  24111. lods: Nullable<any>;
  24112. actions: Nullable<any>;
  24113. freezeWorldMatrix: Nullable<boolean>;
  24114. };
  24115. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  24116. /**
  24117. * Gets or sets a skeleton to apply skining transformations
  24118. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24119. */
  24120. skeleton: Nullable<Skeleton>;
  24121. /**
  24122. * An event triggered when the mesh is rebuilt.
  24123. */
  24124. onRebuildObservable: Observable<AbstractMesh>;
  24125. /**
  24126. * Creates a new AbstractMesh
  24127. * @param name defines the name of the mesh
  24128. * @param scene defines the hosting scene
  24129. */
  24130. constructor(name: string, scene?: Nullable<Scene>);
  24131. /**
  24132. * Returns the string "AbstractMesh"
  24133. * @returns "AbstractMesh"
  24134. */
  24135. getClassName(): string;
  24136. /**
  24137. * Gets a string representation of the current mesh
  24138. * @param fullDetails defines a boolean indicating if full details must be included
  24139. * @returns a string representation of the current mesh
  24140. */
  24141. toString(fullDetails?: boolean): string;
  24142. /**
  24143. * @hidden
  24144. */
  24145. protected _getEffectiveParent(): Nullable<Node>;
  24146. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24147. /** @hidden */ private _rebuild(): void;
  24148. /** @hidden */ private _resyncLightSources(): void;
  24149. /** @hidden */ private _resyncLighSource(light: Light): void;
  24150. /** @hidden */ private _unBindEffect(): void;
  24151. /** @hidden */ private _removeLightSource(light: Light): void;
  24152. private _markSubMeshesAsDirty;
  24153. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  24154. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  24155. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  24156. /**
  24157. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24158. */
  24159. scaling: Vector3;
  24160. /**
  24161. * Returns true if the mesh is blocked. Implemented by child classes
  24162. */
  24163. readonly isBlocked: boolean;
  24164. /**
  24165. * Returns the mesh itself by default. Implemented by child classes
  24166. * @param camera defines the camera to use to pick the right LOD level
  24167. * @returns the currentAbstractMesh
  24168. */
  24169. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24170. /**
  24171. * Returns 0 by default. Implemented by child classes
  24172. * @returns an integer
  24173. */
  24174. getTotalVertices(): number;
  24175. /**
  24176. * Returns a positive integer : the total number of indices in this mesh geometry.
  24177. * @returns the numner of indices or zero if the mesh has no geometry.
  24178. */
  24179. getTotalIndices(): number;
  24180. /**
  24181. * Returns null by default. Implemented by child classes
  24182. * @returns null
  24183. */
  24184. getIndices(): Nullable<IndicesArray>;
  24185. /**
  24186. * Returns the array of the requested vertex data kind. Implemented by child classes
  24187. * @param kind defines the vertex data kind to use
  24188. * @returns null
  24189. */
  24190. getVerticesData(kind: string): Nullable<FloatArray>;
  24191. /**
  24192. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24193. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24194. * Note that a new underlying VertexBuffer object is created each call.
  24195. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24196. * @param kind defines vertex data kind:
  24197. * * VertexBuffer.PositionKind
  24198. * * VertexBuffer.UVKind
  24199. * * VertexBuffer.UV2Kind
  24200. * * VertexBuffer.UV3Kind
  24201. * * VertexBuffer.UV4Kind
  24202. * * VertexBuffer.UV5Kind
  24203. * * VertexBuffer.UV6Kind
  24204. * * VertexBuffer.ColorKind
  24205. * * VertexBuffer.MatricesIndicesKind
  24206. * * VertexBuffer.MatricesIndicesExtraKind
  24207. * * VertexBuffer.MatricesWeightsKind
  24208. * * VertexBuffer.MatricesWeightsExtraKind
  24209. * @param data defines the data source
  24210. * @param updatable defines if the data must be flagged as updatable (or static)
  24211. * @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
  24212. * @returns the current mesh
  24213. */
  24214. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24215. /**
  24216. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  24217. * If the mesh has no geometry, it is simply returned as it is.
  24218. * @param kind defines vertex data kind:
  24219. * * VertexBuffer.PositionKind
  24220. * * VertexBuffer.UVKind
  24221. * * VertexBuffer.UV2Kind
  24222. * * VertexBuffer.UV3Kind
  24223. * * VertexBuffer.UV4Kind
  24224. * * VertexBuffer.UV5Kind
  24225. * * VertexBuffer.UV6Kind
  24226. * * VertexBuffer.ColorKind
  24227. * * VertexBuffer.MatricesIndicesKind
  24228. * * VertexBuffer.MatricesIndicesExtraKind
  24229. * * VertexBuffer.MatricesWeightsKind
  24230. * * VertexBuffer.MatricesWeightsExtraKind
  24231. * @param data defines the data source
  24232. * @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
  24233. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  24234. * @returns the current mesh
  24235. */
  24236. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24237. /**
  24238. * Sets the mesh indices,
  24239. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  24240. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  24241. * @param totalVertices Defines the total number of vertices
  24242. * @returns the current mesh
  24243. */
  24244. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  24245. /**
  24246. * Gets a boolean indicating if specific vertex data is present
  24247. * @param kind defines the vertex data kind to use
  24248. * @returns true is data kind is present
  24249. */
  24250. isVerticesDataPresent(kind: string): boolean;
  24251. /**
  24252. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  24253. * @returns a BoundingInfo
  24254. */
  24255. getBoundingInfo(): BoundingInfo;
  24256. /**
  24257. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  24258. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  24259. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  24260. * @returns the current mesh
  24261. */
  24262. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  24263. /**
  24264. * Overwrite the current bounding info
  24265. * @param boundingInfo defines the new bounding info
  24266. * @returns the current mesh
  24267. */
  24268. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  24269. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  24270. readonly useBones: boolean;
  24271. /** @hidden */ private _preActivate(): void;
  24272. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  24273. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  24274. /** @hidden */ private _postActivate(): void;
  24275. /** @hidden */ private _freeze(): void;
  24276. /** @hidden */ private _unFreeze(): void;
  24277. /**
  24278. * Gets the current world matrix
  24279. * @returns a Matrix
  24280. */
  24281. getWorldMatrix(): Matrix;
  24282. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  24283. /**
  24284. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  24285. */
  24286. readonly isAnInstance: boolean;
  24287. /**
  24288. * Perform relative position change from the point of view of behind the front of the mesh.
  24289. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24290. * Supports definition of mesh facing forward or backward
  24291. * @param amountRight defines the distance on the right axis
  24292. * @param amountUp defines the distance on the up axis
  24293. * @param amountForward defines the distance on the forward axis
  24294. * @returns the current mesh
  24295. */
  24296. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  24297. /**
  24298. * Calculate relative position change from the point of view of behind the front of the mesh.
  24299. * This is performed taking into account the meshes current rotation, so you do not have to care.
  24300. * Supports definition of mesh facing forward or backward
  24301. * @param amountRight defines the distance on the right axis
  24302. * @param amountUp defines the distance on the up axis
  24303. * @param amountForward defines the distance on the forward axis
  24304. * @returns the new displacement vector
  24305. */
  24306. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  24307. /**
  24308. * Perform relative rotation change from the point of view of behind the front of the mesh.
  24309. * Supports definition of mesh facing forward or backward
  24310. * @param flipBack defines the flip
  24311. * @param twirlClockwise defines the twirl
  24312. * @param tiltRight defines the tilt
  24313. * @returns the current mesh
  24314. */
  24315. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  24316. /**
  24317. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  24318. * Supports definition of mesh facing forward or backward.
  24319. * @param flipBack defines the flip
  24320. * @param twirlClockwise defines the twirl
  24321. * @param tiltRight defines the tilt
  24322. * @returns the new rotation vector
  24323. */
  24324. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  24325. /**
  24326. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24327. * This means the mesh underlying bounding box and sphere are recomputed.
  24328. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24329. * @returns the current mesh
  24330. */
  24331. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  24332. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  24333. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  24334. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  24335. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  24336. /** @hidden */
  24337. protected _afterComputeWorldMatrix(): void;
  24338. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  24339. /**
  24340. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24341. * A mesh is in the frustum if its bounding box intersects the frustum
  24342. * @param frustumPlanes defines the frustum to test
  24343. * @returns true if the mesh is in the frustum planes
  24344. */
  24345. isInFrustum(frustumPlanes: Plane[]): boolean;
  24346. /**
  24347. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  24348. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  24349. * @param frustumPlanes defines the frustum to test
  24350. * @returns true if the mesh is completely in the frustum planes
  24351. */
  24352. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  24353. /**
  24354. * True if the mesh intersects another mesh or a SolidParticle object
  24355. * @param mesh defines a target mesh or SolidParticle to test
  24356. * @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)
  24357. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  24358. * @returns true if there is an intersection
  24359. */
  24360. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  24361. /**
  24362. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  24363. * @param point defines the point to test
  24364. * @returns true if there is an intersection
  24365. */
  24366. intersectsPoint(point: Vector3): boolean;
  24367. /**
  24368. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  24369. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24370. */
  24371. checkCollisions: boolean;
  24372. /**
  24373. * Gets Collider object used to compute collisions (not physics)
  24374. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24375. */
  24376. readonly collider: Nullable<Collider>;
  24377. /**
  24378. * Move the mesh using collision engine
  24379. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24380. * @param displacement defines the requested displacement vector
  24381. * @returns the current mesh
  24382. */
  24383. moveWithCollisions(displacement: Vector3): AbstractMesh;
  24384. private _onCollisionPositionChange;
  24385. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  24386. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  24387. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  24388. /** @hidden */ private _generatePointsArray(): boolean;
  24389. /**
  24390. * Checks if the passed Ray intersects with the mesh
  24391. * @param ray defines the ray to use
  24392. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  24393. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  24394. * @returns the picking info
  24395. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24396. */
  24397. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  24398. /**
  24399. * Clones the current mesh
  24400. * @param name defines the mesh name
  24401. * @param newParent defines the new mesh parent
  24402. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  24403. * @returns the new mesh
  24404. */
  24405. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  24406. /**
  24407. * Disposes all the submeshes of the current meshnp
  24408. * @returns the current mesh
  24409. */
  24410. releaseSubMeshes(): AbstractMesh;
  24411. /**
  24412. * Releases resources associated with this abstract mesh.
  24413. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24414. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24415. */
  24416. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24417. /**
  24418. * Adds the passed mesh as a child to the current mesh
  24419. * @param mesh defines the child mesh
  24420. * @returns the current mesh
  24421. */
  24422. addChild(mesh: AbstractMesh): AbstractMesh;
  24423. /**
  24424. * Removes the passed mesh from the current mesh children list
  24425. * @param mesh defines the child mesh
  24426. * @returns the current mesh
  24427. */
  24428. removeChild(mesh: AbstractMesh): AbstractMesh;
  24429. /** @hidden */
  24430. private _initFacetData;
  24431. /**
  24432. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  24433. * This method can be called within the render loop.
  24434. * 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
  24435. * @returns the current mesh
  24436. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24437. */
  24438. updateFacetData(): AbstractMesh;
  24439. /**
  24440. * Returns the facetLocalNormals array.
  24441. * The normals are expressed in the mesh local spac
  24442. * @returns an array of Vector3
  24443. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24444. */
  24445. getFacetLocalNormals(): Vector3[];
  24446. /**
  24447. * Returns the facetLocalPositions array.
  24448. * The facet positions are expressed in the mesh local space
  24449. * @returns an array of Vector3
  24450. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24451. */
  24452. getFacetLocalPositions(): Vector3[];
  24453. /**
  24454. * Returns the facetLocalPartioning array
  24455. * @returns an array of array of numbers
  24456. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24457. */
  24458. getFacetLocalPartitioning(): number[][];
  24459. /**
  24460. * Returns the i-th facet position in the world system.
  24461. * This method allocates a new Vector3 per call
  24462. * @param i defines the facet index
  24463. * @returns a new Vector3
  24464. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24465. */
  24466. getFacetPosition(i: number): Vector3;
  24467. /**
  24468. * Sets the reference Vector3 with the i-th facet position in the world system
  24469. * @param i defines the facet index
  24470. * @param ref defines the target vector
  24471. * @returns the current mesh
  24472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24473. */
  24474. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  24475. /**
  24476. * Returns the i-th facet normal in the world system.
  24477. * This method allocates a new Vector3 per call
  24478. * @param i defines the facet index
  24479. * @returns a new Vector3
  24480. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24481. */
  24482. getFacetNormal(i: number): Vector3;
  24483. /**
  24484. * Sets the reference Vector3 with the i-th facet normal in the world system
  24485. * @param i defines the facet index
  24486. * @param ref defines the target vector
  24487. * @returns the current mesh
  24488. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24489. */
  24490. getFacetNormalToRef(i: number, ref: Vector3): this;
  24491. /**
  24492. * 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)
  24493. * @param x defines x coordinate
  24494. * @param y defines y coordinate
  24495. * @param z defines z coordinate
  24496. * @returns the array of facet indexes
  24497. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24498. */
  24499. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  24500. /**
  24501. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  24502. * @param projected sets as the (x,y,z) world projection on the facet
  24503. * @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
  24504. * @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
  24505. * @param x defines x coordinate
  24506. * @param y defines y coordinate
  24507. * @param z defines z coordinate
  24508. * @returns the face index if found (or null instead)
  24509. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24510. */
  24511. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24512. /**
  24513. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  24514. * @param projected sets as the (x,y,z) local projection on the facet
  24515. * @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
  24516. * @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
  24517. * @param x defines x coordinate
  24518. * @param y defines y coordinate
  24519. * @param z defines z coordinate
  24520. * @returns the face index if found (or null instead)
  24521. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24522. */
  24523. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  24524. /**
  24525. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  24526. * @returns the parameters
  24527. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24528. */
  24529. getFacetDataParameters(): any;
  24530. /**
  24531. * Disables the feature FacetData and frees the related memory
  24532. * @returns the current mesh
  24533. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  24534. */
  24535. disableFacetData(): AbstractMesh;
  24536. /**
  24537. * Updates the AbstractMesh indices array
  24538. * @param indices defines the data source
  24539. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24540. * @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)
  24541. * @returns the current mesh
  24542. */
  24543. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24544. /**
  24545. * Creates new normals data for the mesh
  24546. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  24547. * @returns the current mesh
  24548. */
  24549. createNormals(updatable: boolean): AbstractMesh;
  24550. /**
  24551. * Align the mesh with a normal
  24552. * @param normal defines the normal to use
  24553. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  24554. * @returns the current mesh
  24555. */
  24556. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  24557. /** @hidden */ private _checkOcclusionQuery(): boolean;
  24558. /**
  24559. * Disables the mesh edge rendering mode
  24560. * @returns the currentAbstractMesh
  24561. */
  24562. disableEdgesRendering(): AbstractMesh;
  24563. /**
  24564. * Enables the edge rendering mode on the mesh.
  24565. * This mode makes the mesh edges visible
  24566. * @param epsilon defines the maximal distance between two angles to detect a face
  24567. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  24568. * @returns the currentAbstractMesh
  24569. * @see https://www.babylonjs-playground.com/#19O9TU#0
  24570. */
  24571. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  24572. }
  24573. }
  24574. declare module BABYLON {
  24575. /**
  24576. * Interface used to define ActionEvent
  24577. */
  24578. export interface IActionEvent {
  24579. /** The mesh or sprite that triggered the action */
  24580. source: any;
  24581. /** The X mouse cursor position at the time of the event */
  24582. pointerX: number;
  24583. /** The Y mouse cursor position at the time of the event */
  24584. pointerY: number;
  24585. /** The mesh that is currently pointed at (can be null) */
  24586. meshUnderPointer: Nullable<AbstractMesh>;
  24587. /** the original (browser) event that triggered the ActionEvent */
  24588. sourceEvent?: any;
  24589. /** additional data for the event */
  24590. additionalData?: any;
  24591. }
  24592. /**
  24593. * ActionEvent is the event being sent when an action is triggered.
  24594. */
  24595. export class ActionEvent implements IActionEvent {
  24596. /** The mesh or sprite that triggered the action */
  24597. source: any;
  24598. /** The X mouse cursor position at the time of the event */
  24599. pointerX: number;
  24600. /** The Y mouse cursor position at the time of the event */
  24601. pointerY: number;
  24602. /** The mesh that is currently pointed at (can be null) */
  24603. meshUnderPointer: Nullable<AbstractMesh>;
  24604. /** the original (browser) event that triggered the ActionEvent */
  24605. sourceEvent?: any;
  24606. /** additional data for the event */
  24607. additionalData?: any;
  24608. /**
  24609. * Creates a new ActionEvent
  24610. * @param source The mesh or sprite that triggered the action
  24611. * @param pointerX The X mouse cursor position at the time of the event
  24612. * @param pointerY The Y mouse cursor position at the time of the event
  24613. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  24614. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  24615. * @param additionalData additional data for the event
  24616. */
  24617. constructor(
  24618. /** The mesh or sprite that triggered the action */
  24619. source: any,
  24620. /** The X mouse cursor position at the time of the event */
  24621. pointerX: number,
  24622. /** The Y mouse cursor position at the time of the event */
  24623. pointerY: number,
  24624. /** The mesh that is currently pointed at (can be null) */
  24625. meshUnderPointer: Nullable<AbstractMesh>,
  24626. /** the original (browser) event that triggered the ActionEvent */
  24627. sourceEvent?: any,
  24628. /** additional data for the event */
  24629. additionalData?: any);
  24630. /**
  24631. * Helper function to auto-create an ActionEvent from a source mesh.
  24632. * @param source The source mesh that triggered the event
  24633. * @param evt The original (browser) event
  24634. * @param additionalData additional data for the event
  24635. * @returns the new ActionEvent
  24636. */
  24637. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  24638. /**
  24639. * Helper function to auto-create an ActionEvent from a source sprite
  24640. * @param source The source sprite that triggered the event
  24641. * @param scene Scene associated with the sprite
  24642. * @param evt The original (browser) event
  24643. * @param additionalData additional data for the event
  24644. * @returns the new ActionEvent
  24645. */
  24646. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  24647. /**
  24648. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  24649. * @param scene the scene where the event occurred
  24650. * @param evt The original (browser) event
  24651. * @returns the new ActionEvent
  24652. */
  24653. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  24654. /**
  24655. * Helper function to auto-create an ActionEvent from a primitive
  24656. * @param prim defines the target primitive
  24657. * @param pointerPos defines the pointer position
  24658. * @param evt The original (browser) event
  24659. * @param additionalData additional data for the event
  24660. * @returns the new ActionEvent
  24661. */
  24662. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  24663. }
  24664. }
  24665. declare module BABYLON {
  24666. /**
  24667. * Abstract class used to decouple action Manager from scene and meshes.
  24668. * Do not instantiate.
  24669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24670. */
  24671. export abstract class AbstractActionManager implements IDisposable {
  24672. /** Gets the list of active triggers */
  24673. static Triggers: {
  24674. [key: string]: number;
  24675. };
  24676. /** Gets the cursor to use when hovering items */
  24677. hoverCursor: string;
  24678. /** Gets the list of actions */
  24679. actions: IAction[];
  24680. /**
  24681. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  24682. */
  24683. isRecursive: boolean;
  24684. /**
  24685. * Releases all associated resources
  24686. */
  24687. abstract dispose(): void;
  24688. /**
  24689. * Does this action manager has pointer triggers
  24690. */
  24691. abstract readonly hasPointerTriggers: boolean;
  24692. /**
  24693. * Does this action manager has pick triggers
  24694. */
  24695. abstract readonly hasPickTriggers: boolean;
  24696. /**
  24697. * Process a specific trigger
  24698. * @param trigger defines the trigger to process
  24699. * @param evt defines the event details to be processed
  24700. */
  24701. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  24702. /**
  24703. * Does this action manager handles actions of any of the given triggers
  24704. * @param triggers defines the triggers to be tested
  24705. * @return a boolean indicating whether one (or more) of the triggers is handled
  24706. */
  24707. abstract hasSpecificTriggers(triggers: number[]): boolean;
  24708. /**
  24709. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  24710. * speed.
  24711. * @param triggerA defines the trigger to be tested
  24712. * @param triggerB defines the trigger to be tested
  24713. * @return a boolean indicating whether one (or more) of the triggers is handled
  24714. */
  24715. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  24716. /**
  24717. * Does this action manager handles actions of a given trigger
  24718. * @param trigger defines the trigger to be tested
  24719. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  24720. * @return whether the trigger is handled
  24721. */
  24722. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  24723. /**
  24724. * Serialize this manager to a JSON object
  24725. * @param name defines the property name to store this manager
  24726. * @returns a JSON representation of this manager
  24727. */
  24728. abstract serialize(name: string): any;
  24729. /**
  24730. * Registers an action to this action manager
  24731. * @param action defines the action to be registered
  24732. * @return the action amended (prepared) after registration
  24733. */
  24734. abstract registerAction(action: IAction): Nullable<IAction>;
  24735. /**
  24736. * Unregisters an action to this action manager
  24737. * @param action defines the action to be unregistered
  24738. * @return a boolean indicating whether the action has been unregistered
  24739. */
  24740. abstract unregisterAction(action: IAction): Boolean;
  24741. /**
  24742. * Does exist one action manager with at least one trigger
  24743. **/
  24744. static readonly HasTriggers: boolean;
  24745. /**
  24746. * Does exist one action manager with at least one pick trigger
  24747. **/
  24748. static readonly HasPickTriggers: boolean;
  24749. /**
  24750. * Does exist one action manager that handles actions of a given trigger
  24751. * @param trigger defines the trigger to be tested
  24752. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  24753. **/
  24754. static HasSpecificTrigger(trigger: number): boolean;
  24755. }
  24756. }
  24757. declare module BABYLON {
  24758. /**
  24759. * Defines how a node can be built from a string name.
  24760. */
  24761. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  24762. /**
  24763. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  24764. */
  24765. export class Node implements IBehaviorAware<Node> {
  24766. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  24767. private static _NodeConstructors;
  24768. /**
  24769. * Add a new node constructor
  24770. * @param type defines the type name of the node to construct
  24771. * @param constructorFunc defines the constructor function
  24772. */
  24773. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  24774. /**
  24775. * Returns a node constructor based on type name
  24776. * @param type defines the type name
  24777. * @param name defines the new node name
  24778. * @param scene defines the hosting scene
  24779. * @param options defines optional options to transmit to constructors
  24780. * @returns the new constructor or null
  24781. */
  24782. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  24783. /**
  24784. * Gets or sets the name of the node
  24785. */
  24786. name: string;
  24787. /**
  24788. * Gets or sets the id of the node
  24789. */
  24790. id: string;
  24791. /**
  24792. * Gets or sets the unique id of the node
  24793. */
  24794. uniqueId: number;
  24795. /**
  24796. * Gets or sets a string used to store user defined state for the node
  24797. */
  24798. state: string;
  24799. /**
  24800. * Gets or sets an object used to store user defined information for the node
  24801. */
  24802. metadata: any;
  24803. /**
  24804. * For internal use only. Please do not use.
  24805. */
  24806. reservedDataStore: any;
  24807. /**
  24808. * List of inspectable custom properties (used by the Inspector)
  24809. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24810. */
  24811. inspectableCustomProperties: IInspectable[];
  24812. /**
  24813. * Gets or sets a boolean used to define if the node must be serialized
  24814. */
  24815. doNotSerialize: boolean;
  24816. /** @hidden */ private _isDisposed: boolean;
  24817. /**
  24818. * Gets a list of Animations associated with the node
  24819. */
  24820. animations: Animation[];
  24821. protected _ranges: {
  24822. [name: string]: Nullable<AnimationRange>;
  24823. };
  24824. /**
  24825. * Callback raised when the node is ready to be used
  24826. */
  24827. onReady: Nullable<(node: Node) => void>;
  24828. private _isEnabled;
  24829. private _isParentEnabled;
  24830. private _isReady;
  24831. /** @hidden */ private _currentRenderId: number;
  24832. private _parentUpdateId;
  24833. /** @hidden */ private _childUpdateId: number;
  24834. /** @hidden */ private _waitingParentId: Nullable<string>;
  24835. /** @hidden */ private _scene: Scene;
  24836. /** @hidden */ private _cache: any;
  24837. private _parentNode;
  24838. private _children;
  24839. /** @hidden */ private _worldMatrix: Matrix;
  24840. /** @hidden */ private _worldMatrixDeterminant: number;
  24841. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  24842. /** @hidden */
  24843. private _sceneRootNodesIndex;
  24844. /**
  24845. * Gets a boolean indicating if the node has been disposed
  24846. * @returns true if the node was disposed
  24847. */
  24848. isDisposed(): boolean;
  24849. /**
  24850. * Gets or sets the parent of the node (without keeping the current position in the scene)
  24851. * @see https://doc.babylonjs.com/how_to/parenting
  24852. */
  24853. parent: Nullable<Node>;
  24854. private addToSceneRootNodes;
  24855. private removeFromSceneRootNodes;
  24856. private _animationPropertiesOverride;
  24857. /**
  24858. * Gets or sets the animation properties override
  24859. */
  24860. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  24861. /**
  24862. * Gets a string idenfifying the name of the class
  24863. * @returns "Node" string
  24864. */
  24865. getClassName(): string;
  24866. /** @hidden */ protected readonly _isNode: boolean;
  24867. /**
  24868. * An event triggered when the mesh is disposed
  24869. */
  24870. onDisposeObservable: Observable<Node>;
  24871. private _onDisposeObserver;
  24872. /**
  24873. * Sets a callback that will be raised when the node will be disposed
  24874. */
  24875. onDispose: () => void;
  24876. /**
  24877. * Creates a new Node
  24878. * @param name the name and id to be given to this node
  24879. * @param scene the scene this node will be added to
  24880. * @param addToRootNodes the node will be added to scene.rootNodes
  24881. */
  24882. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  24883. /**
  24884. * Gets the scene of the node
  24885. * @returns a scene
  24886. */
  24887. getScene(): Scene;
  24888. /**
  24889. * Gets the engine of the node
  24890. * @returns a Engine
  24891. */
  24892. getEngine(): Engine;
  24893. private _behaviors;
  24894. /**
  24895. * Attach a behavior to the node
  24896. * @see http://doc.babylonjs.com/features/behaviour
  24897. * @param behavior defines the behavior to attach
  24898. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  24899. * @returns the current Node
  24900. */
  24901. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  24902. /**
  24903. * Remove an attached behavior
  24904. * @see http://doc.babylonjs.com/features/behaviour
  24905. * @param behavior defines the behavior to attach
  24906. * @returns the current Node
  24907. */
  24908. removeBehavior(behavior: Behavior<Node>): Node;
  24909. /**
  24910. * Gets the list of attached behaviors
  24911. * @see http://doc.babylonjs.com/features/behaviour
  24912. */
  24913. readonly behaviors: Behavior<Node>[];
  24914. /**
  24915. * Gets an attached behavior by name
  24916. * @param name defines the name of the behavior to look for
  24917. * @see http://doc.babylonjs.com/features/behaviour
  24918. * @returns null if behavior was not found else the requested behavior
  24919. */
  24920. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  24921. /**
  24922. * Returns the latest update of the World matrix
  24923. * @returns a Matrix
  24924. */
  24925. getWorldMatrix(): Matrix;
  24926. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  24927. /**
  24928. * Returns directly the latest state of the mesh World matrix.
  24929. * A Matrix is returned.
  24930. */
  24931. readonly worldMatrixFromCache: Matrix;
  24932. /** @hidden */ private _initCache(): void;
  24933. /** @hidden */
  24934. updateCache(force?: boolean): void;
  24935. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24936. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24937. /** @hidden */ private _isSynchronized(): boolean;
  24938. /** @hidden */ private _markSyncedWithParent(): void;
  24939. /** @hidden */
  24940. isSynchronizedWithParent(): boolean;
  24941. /** @hidden */
  24942. isSynchronized(): boolean;
  24943. /**
  24944. * Is this node ready to be used/rendered
  24945. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24946. * @return true if the node is ready
  24947. */
  24948. isReady(completeCheck?: boolean): boolean;
  24949. /**
  24950. * Is this node enabled?
  24951. * 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
  24952. * @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
  24953. * @return whether this node (and its parent) is enabled
  24954. */
  24955. isEnabled(checkAncestors?: boolean): boolean;
  24956. /** @hidden */
  24957. protected _syncParentEnabledState(): void;
  24958. /**
  24959. * Set the enabled state of this node
  24960. * @param value defines the new enabled state
  24961. */
  24962. setEnabled(value: boolean): void;
  24963. /**
  24964. * Is this node a descendant of the given node?
  24965. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  24966. * @param ancestor defines the parent node to inspect
  24967. * @returns a boolean indicating if this node is a descendant of the given node
  24968. */
  24969. isDescendantOf(ancestor: Node): boolean;
  24970. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  24971. /**
  24972. * Will return all nodes that have this node as ascendant
  24973. * @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
  24974. * @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
  24975. * @return all children nodes of all types
  24976. */
  24977. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  24978. /**
  24979. * Get all child-meshes of this node
  24980. * @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)
  24981. * @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
  24982. * @returns an array of AbstractMesh
  24983. */
  24984. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  24985. /**
  24986. * Get all direct children of this node
  24987. * @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
  24988. * @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)
  24989. * @returns an array of Node
  24990. */
  24991. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  24992. /** @hidden */ private _setReady(state: boolean): void;
  24993. /**
  24994. * Get an animation by name
  24995. * @param name defines the name of the animation to look for
  24996. * @returns null if not found else the requested animation
  24997. */
  24998. getAnimationByName(name: string): Nullable<Animation>;
  24999. /**
  25000. * Creates an animation range for this node
  25001. * @param name defines the name of the range
  25002. * @param from defines the starting key
  25003. * @param to defines the end key
  25004. */
  25005. createAnimationRange(name: string, from: number, to: number): void;
  25006. /**
  25007. * Delete a specific animation range
  25008. * @param name defines the name of the range to delete
  25009. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25010. */
  25011. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25012. /**
  25013. * Get an animation range by name
  25014. * @param name defines the name of the animation range to look for
  25015. * @returns null if not found else the requested animation range
  25016. */
  25017. getAnimationRange(name: string): Nullable<AnimationRange>;
  25018. /**
  25019. * Gets the list of all animation ranges defined on this node
  25020. * @returns an array
  25021. */
  25022. getAnimationRanges(): Nullable<AnimationRange>[];
  25023. /**
  25024. * Will start the animation sequence
  25025. * @param name defines the range frames for animation sequence
  25026. * @param loop defines if the animation should loop (false by default)
  25027. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25028. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25029. * @returns the object created for this animation. If range does not exist, it will return null
  25030. */
  25031. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25032. /**
  25033. * Serialize animation ranges into a JSON compatible object
  25034. * @returns serialization object
  25035. */
  25036. serializeAnimationRanges(): any;
  25037. /**
  25038. * Computes the world matrix of the node
  25039. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25040. * @returns the world matrix
  25041. */
  25042. computeWorldMatrix(force?: boolean): Matrix;
  25043. /**
  25044. * Releases resources associated with this node.
  25045. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25046. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25047. */
  25048. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25049. /**
  25050. * Parse animation range data from a serialization object and store them into a given node
  25051. * @param node defines where to store the animation ranges
  25052. * @param parsedNode defines the serialization object to read data from
  25053. * @param scene defines the hosting scene
  25054. */
  25055. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25056. /**
  25057. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25058. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25059. * @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
  25060. * @returns the new bounding vectors
  25061. */
  25062. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25063. min: Vector3;
  25064. max: Vector3;
  25065. };
  25066. }
  25067. }
  25068. declare module BABYLON {
  25069. /**
  25070. * @hidden
  25071. */
  25072. export class _IAnimationState {
  25073. key: number;
  25074. repeatCount: number;
  25075. workValue?: any;
  25076. loopMode?: number;
  25077. offsetValue?: any;
  25078. highLimitValue?: any;
  25079. }
  25080. /**
  25081. * Class used to store any kind of animation
  25082. */
  25083. export class Animation {
  25084. /**Name of the animation */
  25085. name: string;
  25086. /**Property to animate */
  25087. targetProperty: string;
  25088. /**The frames per second of the animation */
  25089. framePerSecond: number;
  25090. /**The data type of the animation */
  25091. dataType: number;
  25092. /**The loop mode of the animation */
  25093. loopMode?: number | undefined;
  25094. /**Specifies if blending should be enabled */
  25095. enableBlending?: boolean | undefined;
  25096. /**
  25097. * Use matrix interpolation instead of using direct key value when animating matrices
  25098. */
  25099. static AllowMatricesInterpolation: boolean;
  25100. /**
  25101. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25102. */
  25103. static AllowMatrixDecomposeForInterpolation: boolean;
  25104. /**
  25105. * Stores the key frames of the animation
  25106. */
  25107. private _keys;
  25108. /**
  25109. * Stores the easing function of the animation
  25110. */
  25111. private _easingFunction;
  25112. /**
  25113. * @hidden Internal use only
  25114. */ private _runtimeAnimations: RuntimeAnimation[];
  25115. /**
  25116. * The set of event that will be linked to this animation
  25117. */
  25118. private _events;
  25119. /**
  25120. * Stores an array of target property paths
  25121. */
  25122. targetPropertyPath: string[];
  25123. /**
  25124. * Stores the blending speed of the animation
  25125. */
  25126. blendingSpeed: number;
  25127. /**
  25128. * Stores the animation ranges for the animation
  25129. */
  25130. private _ranges;
  25131. /**
  25132. * @hidden Internal use
  25133. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25134. /**
  25135. * Sets up an animation
  25136. * @param property The property to animate
  25137. * @param animationType The animation type to apply
  25138. * @param framePerSecond The frames per second of the animation
  25139. * @param easingFunction The easing function used in the animation
  25140. * @returns The created animation
  25141. */
  25142. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25143. /**
  25144. * Create and start an animation on a node
  25145. * @param name defines the name of the global animation that will be run on all nodes
  25146. * @param node defines the root node where the animation will take place
  25147. * @param targetProperty defines property to animate
  25148. * @param framePerSecond defines the number of frame per second yo use
  25149. * @param totalFrame defines the number of frames in total
  25150. * @param from defines the initial value
  25151. * @param to defines the final value
  25152. * @param loopMode defines which loop mode you want to use (off by default)
  25153. * @param easingFunction defines the easing function to use (linear by default)
  25154. * @param onAnimationEnd defines the callback to call when animation end
  25155. * @returns the animatable created for this animation
  25156. */
  25157. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25158. /**
  25159. * Create and start an animation on a node and its descendants
  25160. * @param name defines the name of the global animation that will be run on all nodes
  25161. * @param node defines the root node where the animation will take place
  25162. * @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
  25163. * @param targetProperty defines property to animate
  25164. * @param framePerSecond defines the number of frame per second to use
  25165. * @param totalFrame defines the number of frames in total
  25166. * @param from defines the initial value
  25167. * @param to defines the final value
  25168. * @param loopMode defines which loop mode you want to use (off by default)
  25169. * @param easingFunction defines the easing function to use (linear by default)
  25170. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  25171. * @returns the list of animatables created for all nodes
  25172. * @example https://www.babylonjs-playground.com/#MH0VLI
  25173. */
  25174. 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[]>;
  25175. /**
  25176. * Creates a new animation, merges it with the existing animations and starts it
  25177. * @param name Name of the animation
  25178. * @param node Node which contains the scene that begins the animations
  25179. * @param targetProperty Specifies which property to animate
  25180. * @param framePerSecond The frames per second of the animation
  25181. * @param totalFrame The total number of frames
  25182. * @param from The frame at the beginning of the animation
  25183. * @param to The frame at the end of the animation
  25184. * @param loopMode Specifies the loop mode of the animation
  25185. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  25186. * @param onAnimationEnd Callback to run once the animation is complete
  25187. * @returns Nullable animation
  25188. */
  25189. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25190. /**
  25191. * Transition property of an host to the target Value
  25192. * @param property The property to transition
  25193. * @param targetValue The target Value of the property
  25194. * @param host The object where the property to animate belongs
  25195. * @param scene Scene used to run the animation
  25196. * @param frameRate Framerate (in frame/s) to use
  25197. * @param transition The transition type we want to use
  25198. * @param duration The duration of the animation, in milliseconds
  25199. * @param onAnimationEnd Callback trigger at the end of the animation
  25200. * @returns Nullable animation
  25201. */
  25202. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  25203. /**
  25204. * Return the array of runtime animations currently using this animation
  25205. */
  25206. readonly runtimeAnimations: RuntimeAnimation[];
  25207. /**
  25208. * Specifies if any of the runtime animations are currently running
  25209. */
  25210. readonly hasRunningRuntimeAnimations: boolean;
  25211. /**
  25212. * Initializes the animation
  25213. * @param name Name of the animation
  25214. * @param targetProperty Property to animate
  25215. * @param framePerSecond The frames per second of the animation
  25216. * @param dataType The data type of the animation
  25217. * @param loopMode The loop mode of the animation
  25218. * @param enableBlending Specifies if blending should be enabled
  25219. */
  25220. constructor(
  25221. /**Name of the animation */
  25222. name: string,
  25223. /**Property to animate */
  25224. targetProperty: string,
  25225. /**The frames per second of the animation */
  25226. framePerSecond: number,
  25227. /**The data type of the animation */
  25228. dataType: number,
  25229. /**The loop mode of the animation */
  25230. loopMode?: number | undefined,
  25231. /**Specifies if blending should be enabled */
  25232. enableBlending?: boolean | undefined);
  25233. /**
  25234. * Converts the animation to a string
  25235. * @param fullDetails support for multiple levels of logging within scene loading
  25236. * @returns String form of the animation
  25237. */
  25238. toString(fullDetails?: boolean): string;
  25239. /**
  25240. * Add an event to this animation
  25241. * @param event Event to add
  25242. */
  25243. addEvent(event: AnimationEvent): void;
  25244. /**
  25245. * Remove all events found at the given frame
  25246. * @param frame The frame to remove events from
  25247. */
  25248. removeEvents(frame: number): void;
  25249. /**
  25250. * Retrieves all the events from the animation
  25251. * @returns Events from the animation
  25252. */
  25253. getEvents(): AnimationEvent[];
  25254. /**
  25255. * Creates an animation range
  25256. * @param name Name of the animation range
  25257. * @param from Starting frame of the animation range
  25258. * @param to Ending frame of the animation
  25259. */
  25260. createRange(name: string, from: number, to: number): void;
  25261. /**
  25262. * Deletes an animation range by name
  25263. * @param name Name of the animation range to delete
  25264. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  25265. */
  25266. deleteRange(name: string, deleteFrames?: boolean): void;
  25267. /**
  25268. * Gets the animation range by name, or null if not defined
  25269. * @param name Name of the animation range
  25270. * @returns Nullable animation range
  25271. */
  25272. getRange(name: string): Nullable<AnimationRange>;
  25273. /**
  25274. * Gets the key frames from the animation
  25275. * @returns The key frames of the animation
  25276. */
  25277. getKeys(): Array<IAnimationKey>;
  25278. /**
  25279. * Gets the highest frame rate of the animation
  25280. * @returns Highest frame rate of the animation
  25281. */
  25282. getHighestFrame(): number;
  25283. /**
  25284. * Gets the easing function of the animation
  25285. * @returns Easing function of the animation
  25286. */
  25287. getEasingFunction(): IEasingFunction;
  25288. /**
  25289. * Sets the easing function of the animation
  25290. * @param easingFunction A custom mathematical formula for animation
  25291. */
  25292. setEasingFunction(easingFunction: EasingFunction): void;
  25293. /**
  25294. * Interpolates a scalar linearly
  25295. * @param startValue Start value of the animation curve
  25296. * @param endValue End value of the animation curve
  25297. * @param gradient Scalar amount to interpolate
  25298. * @returns Interpolated scalar value
  25299. */
  25300. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  25301. /**
  25302. * Interpolates a scalar cubically
  25303. * @param startValue Start value of the animation curve
  25304. * @param outTangent End tangent of the animation
  25305. * @param endValue End value of the animation curve
  25306. * @param inTangent Start tangent of the animation curve
  25307. * @param gradient Scalar amount to interpolate
  25308. * @returns Interpolated scalar value
  25309. */
  25310. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  25311. /**
  25312. * Interpolates a quaternion using a spherical linear interpolation
  25313. * @param startValue Start value of the animation curve
  25314. * @param endValue End value of the animation curve
  25315. * @param gradient Scalar amount to interpolate
  25316. * @returns Interpolated quaternion value
  25317. */
  25318. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  25319. /**
  25320. * Interpolates a quaternion cubically
  25321. * @param startValue Start value of the animation curve
  25322. * @param outTangent End tangent of the animation curve
  25323. * @param endValue End value of the animation curve
  25324. * @param inTangent Start tangent of the animation curve
  25325. * @param gradient Scalar amount to interpolate
  25326. * @returns Interpolated quaternion value
  25327. */
  25328. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  25329. /**
  25330. * Interpolates a Vector3 linearl
  25331. * @param startValue Start value of the animation curve
  25332. * @param endValue End value of the animation curve
  25333. * @param gradient Scalar amount to interpolate
  25334. * @returns Interpolated scalar value
  25335. */
  25336. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  25337. /**
  25338. * Interpolates a Vector3 cubically
  25339. * @param startValue Start value of the animation curve
  25340. * @param outTangent End tangent of the animation
  25341. * @param endValue End value of the animation curve
  25342. * @param inTangent Start tangent of the animation curve
  25343. * @param gradient Scalar amount to interpolate
  25344. * @returns InterpolatedVector3 value
  25345. */
  25346. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  25347. /**
  25348. * Interpolates a Vector2 linearly
  25349. * @param startValue Start value of the animation curve
  25350. * @param endValue End value of the animation curve
  25351. * @param gradient Scalar amount to interpolate
  25352. * @returns Interpolated Vector2 value
  25353. */
  25354. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  25355. /**
  25356. * Interpolates a Vector2 cubically
  25357. * @param startValue Start value of the animation curve
  25358. * @param outTangent End tangent of the animation
  25359. * @param endValue End value of the animation curve
  25360. * @param inTangent Start tangent of the animation curve
  25361. * @param gradient Scalar amount to interpolate
  25362. * @returns Interpolated Vector2 value
  25363. */
  25364. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  25365. /**
  25366. * Interpolates a size linearly
  25367. * @param startValue Start value of the animation curve
  25368. * @param endValue End value of the animation curve
  25369. * @param gradient Scalar amount to interpolate
  25370. * @returns Interpolated Size value
  25371. */
  25372. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  25373. /**
  25374. * Interpolates a Color3 linearly
  25375. * @param startValue Start value of the animation curve
  25376. * @param endValue End value of the animation curve
  25377. * @param gradient Scalar amount to interpolate
  25378. * @returns Interpolated Color3 value
  25379. */
  25380. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  25381. /**
  25382. * @hidden Internal use only
  25383. */ private _getKeyValue(value: any): any;
  25384. /**
  25385. * @hidden Internal use only
  25386. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  25387. /**
  25388. * Defines the function to use to interpolate matrices
  25389. * @param startValue defines the start matrix
  25390. * @param endValue defines the end matrix
  25391. * @param gradient defines the gradient between both matrices
  25392. * @param result defines an optional target matrix where to store the interpolation
  25393. * @returns the interpolated matrix
  25394. */
  25395. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  25396. /**
  25397. * Makes a copy of the animation
  25398. * @returns Cloned animation
  25399. */
  25400. clone(): Animation;
  25401. /**
  25402. * Sets the key frames of the animation
  25403. * @param values The animation key frames to set
  25404. */
  25405. setKeys(values: Array<IAnimationKey>): void;
  25406. /**
  25407. * Serializes the animation to an object
  25408. * @returns Serialized object
  25409. */
  25410. serialize(): any;
  25411. /**
  25412. * Float animation type
  25413. */
  25414. private static _ANIMATIONTYPE_FLOAT;
  25415. /**
  25416. * Vector3 animation type
  25417. */
  25418. private static _ANIMATIONTYPE_VECTOR3;
  25419. /**
  25420. * Quaternion animation type
  25421. */
  25422. private static _ANIMATIONTYPE_QUATERNION;
  25423. /**
  25424. * Matrix animation type
  25425. */
  25426. private static _ANIMATIONTYPE_MATRIX;
  25427. /**
  25428. * Color3 animation type
  25429. */
  25430. private static _ANIMATIONTYPE_COLOR3;
  25431. /**
  25432. * Vector2 animation type
  25433. */
  25434. private static _ANIMATIONTYPE_VECTOR2;
  25435. /**
  25436. * Size animation type
  25437. */
  25438. private static _ANIMATIONTYPE_SIZE;
  25439. /**
  25440. * Relative Loop Mode
  25441. */
  25442. private static _ANIMATIONLOOPMODE_RELATIVE;
  25443. /**
  25444. * Cycle Loop Mode
  25445. */
  25446. private static _ANIMATIONLOOPMODE_CYCLE;
  25447. /**
  25448. * Constant Loop Mode
  25449. */
  25450. private static _ANIMATIONLOOPMODE_CONSTANT;
  25451. /**
  25452. * Get the float animation type
  25453. */
  25454. static readonly ANIMATIONTYPE_FLOAT: number;
  25455. /**
  25456. * Get the Vector3 animation type
  25457. */
  25458. static readonly ANIMATIONTYPE_VECTOR3: number;
  25459. /**
  25460. * Get the Vector2 animation type
  25461. */
  25462. static readonly ANIMATIONTYPE_VECTOR2: number;
  25463. /**
  25464. * Get the Size animation type
  25465. */
  25466. static readonly ANIMATIONTYPE_SIZE: number;
  25467. /**
  25468. * Get the Quaternion animation type
  25469. */
  25470. static readonly ANIMATIONTYPE_QUATERNION: number;
  25471. /**
  25472. * Get the Matrix animation type
  25473. */
  25474. static readonly ANIMATIONTYPE_MATRIX: number;
  25475. /**
  25476. * Get the Color3 animation type
  25477. */
  25478. static readonly ANIMATIONTYPE_COLOR3: number;
  25479. /**
  25480. * Get the Relative Loop Mode
  25481. */
  25482. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  25483. /**
  25484. * Get the Cycle Loop Mode
  25485. */
  25486. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  25487. /**
  25488. * Get the Constant Loop Mode
  25489. */
  25490. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  25491. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  25492. /**
  25493. * Parses an animation object and creates an animation
  25494. * @param parsedAnimation Parsed animation object
  25495. * @returns Animation object
  25496. */
  25497. static Parse(parsedAnimation: any): Animation;
  25498. /**
  25499. * Appends the serialized animations from the source animations
  25500. * @param source Source containing the animations
  25501. * @param destination Target to store the animations
  25502. */
  25503. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  25504. }
  25505. }
  25506. declare module BABYLON {
  25507. /**
  25508. * Base class of all the textures in babylon.
  25509. * It groups all the common properties the materials, post process, lights... might need
  25510. * in order to make a correct use of the texture.
  25511. */
  25512. export class BaseTexture implements IAnimatable {
  25513. /**
  25514. * Default anisotropic filtering level for the application.
  25515. * It is set to 4 as a good tradeoff between perf and quality.
  25516. */
  25517. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  25518. /**
  25519. * Gets or sets the unique id of the texture
  25520. */
  25521. uniqueId: number;
  25522. /**
  25523. * Define the name of the texture.
  25524. */
  25525. name: string;
  25526. /**
  25527. * Gets or sets an object used to store user defined information.
  25528. */
  25529. metadata: any;
  25530. /**
  25531. * For internal use only. Please do not use.
  25532. */
  25533. reservedDataStore: any;
  25534. private _hasAlpha;
  25535. /**
  25536. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  25537. */
  25538. hasAlpha: boolean;
  25539. /**
  25540. * Defines if the alpha value should be determined via the rgb values.
  25541. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  25542. */
  25543. getAlphaFromRGB: boolean;
  25544. /**
  25545. * Intensity or strength of the texture.
  25546. * It is commonly used by materials to fine tune the intensity of the texture
  25547. */
  25548. level: number;
  25549. /**
  25550. * Define the UV chanel to use starting from 0 and defaulting to 0.
  25551. * This is part of the texture as textures usually maps to one uv set.
  25552. */
  25553. coordinatesIndex: number;
  25554. private _coordinatesMode;
  25555. /**
  25556. * How a texture is mapped.
  25557. *
  25558. * | Value | Type | Description |
  25559. * | ----- | ----------------------------------- | ----------- |
  25560. * | 0 | EXPLICIT_MODE | |
  25561. * | 1 | SPHERICAL_MODE | |
  25562. * | 2 | PLANAR_MODE | |
  25563. * | 3 | CUBIC_MODE | |
  25564. * | 4 | PROJECTION_MODE | |
  25565. * | 5 | SKYBOX_MODE | |
  25566. * | 6 | INVCUBIC_MODE | |
  25567. * | 7 | EQUIRECTANGULAR_MODE | |
  25568. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  25569. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  25570. */
  25571. coordinatesMode: number;
  25572. /**
  25573. * | Value | Type | Description |
  25574. * | ----- | ------------------ | ----------- |
  25575. * | 0 | CLAMP_ADDRESSMODE | |
  25576. * | 1 | WRAP_ADDRESSMODE | |
  25577. * | 2 | MIRROR_ADDRESSMODE | |
  25578. */
  25579. wrapU: number;
  25580. /**
  25581. * | Value | Type | Description |
  25582. * | ----- | ------------------ | ----------- |
  25583. * | 0 | CLAMP_ADDRESSMODE | |
  25584. * | 1 | WRAP_ADDRESSMODE | |
  25585. * | 2 | MIRROR_ADDRESSMODE | |
  25586. */
  25587. wrapV: number;
  25588. /**
  25589. * | Value | Type | Description |
  25590. * | ----- | ------------------ | ----------- |
  25591. * | 0 | CLAMP_ADDRESSMODE | |
  25592. * | 1 | WRAP_ADDRESSMODE | |
  25593. * | 2 | MIRROR_ADDRESSMODE | |
  25594. */
  25595. wrapR: number;
  25596. /**
  25597. * With compliant hardware and browser (supporting anisotropic filtering)
  25598. * this defines the level of anisotropic filtering in the texture.
  25599. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  25600. */
  25601. anisotropicFilteringLevel: number;
  25602. /**
  25603. * Define if the texture is a cube texture or if false a 2d texture.
  25604. */
  25605. isCube: boolean;
  25606. /**
  25607. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  25608. */
  25609. is3D: boolean;
  25610. /**
  25611. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  25612. * HDR texture are usually stored in linear space.
  25613. * This only impacts the PBR and Background materials
  25614. */
  25615. gammaSpace: boolean;
  25616. /**
  25617. * Gets whether or not the texture contains RGBD data.
  25618. */
  25619. readonly isRGBD: boolean;
  25620. /**
  25621. * Is Z inverted in the texture (useful in a cube texture).
  25622. */
  25623. invertZ: boolean;
  25624. /**
  25625. * Are mip maps generated for this texture or not.
  25626. */
  25627. readonly noMipmap: boolean;
  25628. /**
  25629. * @hidden
  25630. */
  25631. lodLevelInAlpha: boolean;
  25632. /**
  25633. * With prefiltered texture, defined the offset used during the prefiltering steps.
  25634. */
  25635. lodGenerationOffset: number;
  25636. /**
  25637. * With prefiltered texture, defined the scale used during the prefiltering steps.
  25638. */
  25639. lodGenerationScale: number;
  25640. /**
  25641. * Define if the texture is a render target.
  25642. */
  25643. isRenderTarget: boolean;
  25644. /**
  25645. * Define the unique id of the texture in the scene.
  25646. */
  25647. readonly uid: string;
  25648. /**
  25649. * Return a string representation of the texture.
  25650. * @returns the texture as a string
  25651. */
  25652. toString(): string;
  25653. /**
  25654. * Get the class name of the texture.
  25655. * @returns "BaseTexture"
  25656. */
  25657. getClassName(): string;
  25658. /**
  25659. * Define the list of animation attached to the texture.
  25660. */
  25661. animations: Animation[];
  25662. /**
  25663. * An event triggered when the texture is disposed.
  25664. */
  25665. onDisposeObservable: Observable<BaseTexture>;
  25666. private _onDisposeObserver;
  25667. /**
  25668. * Callback triggered when the texture has been disposed.
  25669. * Kept for back compatibility, you can use the onDisposeObservable instead.
  25670. */
  25671. onDispose: () => void;
  25672. /**
  25673. * Define the current state of the loading sequence when in delayed load mode.
  25674. */
  25675. delayLoadState: number;
  25676. private _scene;
  25677. /** @hidden */ private _texture: Nullable<InternalTexture>;
  25678. private _uid;
  25679. /**
  25680. * Define if the texture is preventinga material to render or not.
  25681. * If not and the texture is not ready, the engine will use a default black texture instead.
  25682. */
  25683. readonly isBlocking: boolean;
  25684. /**
  25685. * Instantiates a new BaseTexture.
  25686. * Base class of all the textures in babylon.
  25687. * It groups all the common properties the materials, post process, lights... might need
  25688. * in order to make a correct use of the texture.
  25689. * @param scene Define the scene the texture blongs to
  25690. */
  25691. constructor(scene: Nullable<Scene>);
  25692. /**
  25693. * Get the scene the texture belongs to.
  25694. * @returns the scene or null if undefined
  25695. */
  25696. getScene(): Nullable<Scene>;
  25697. /**
  25698. * Get the texture transform matrix used to offset tile the texture for istance.
  25699. * @returns the transformation matrix
  25700. */
  25701. getTextureMatrix(): Matrix;
  25702. /**
  25703. * Get the texture reflection matrix used to rotate/transform the reflection.
  25704. * @returns the reflection matrix
  25705. */
  25706. getReflectionTextureMatrix(): Matrix;
  25707. /**
  25708. * Get the underlying lower level texture from Babylon.
  25709. * @returns the insternal texture
  25710. */
  25711. getInternalTexture(): Nullable<InternalTexture>;
  25712. /**
  25713. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  25714. * @returns true if ready or not blocking
  25715. */
  25716. isReadyOrNotBlocking(): boolean;
  25717. /**
  25718. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  25719. * @returns true if fully ready
  25720. */
  25721. isReady(): boolean;
  25722. private _cachedSize;
  25723. /**
  25724. * Get the size of the texture.
  25725. * @returns the texture size.
  25726. */
  25727. getSize(): ISize;
  25728. /**
  25729. * Get the base size of the texture.
  25730. * It can be different from the size if the texture has been resized for POT for instance
  25731. * @returns the base size
  25732. */
  25733. getBaseSize(): ISize;
  25734. /**
  25735. * Update the sampling mode of the texture.
  25736. * Default is Trilinear mode.
  25737. *
  25738. * | Value | Type | Description |
  25739. * | ----- | ------------------ | ----------- |
  25740. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  25741. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  25742. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  25743. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  25744. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  25745. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  25746. * | 7 | NEAREST_LINEAR | |
  25747. * | 8 | NEAREST_NEAREST | |
  25748. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  25749. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  25750. * | 11 | LINEAR_LINEAR | |
  25751. * | 12 | LINEAR_NEAREST | |
  25752. *
  25753. * > _mag_: magnification filter (close to the viewer)
  25754. * > _min_: minification filter (far from the viewer)
  25755. * > _mip_: filter used between mip map levels
  25756. *@param samplingMode Define the new sampling mode of the texture
  25757. */
  25758. updateSamplingMode(samplingMode: number): void;
  25759. /**
  25760. * Scales the texture if is `canRescale()`
  25761. * @param ratio the resize factor we want to use to rescale
  25762. */
  25763. scale(ratio: number): void;
  25764. /**
  25765. * Get if the texture can rescale.
  25766. */
  25767. readonly canRescale: boolean;
  25768. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  25769. /** @hidden */ private _rebuild(): void;
  25770. /**
  25771. * Triggers the load sequence in delayed load mode.
  25772. */
  25773. delayLoad(): void;
  25774. /**
  25775. * Clones the texture.
  25776. * @returns the cloned texture
  25777. */
  25778. clone(): Nullable<BaseTexture>;
  25779. /**
  25780. * Get the texture underlying type (INT, FLOAT...)
  25781. */
  25782. readonly textureType: number;
  25783. /**
  25784. * Get the texture underlying format (RGB, RGBA...)
  25785. */
  25786. readonly textureFormat: number;
  25787. /**
  25788. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  25789. * This will returns an RGBA array buffer containing either in values (0-255) or
  25790. * float values (0-1) depending of the underlying buffer type.
  25791. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  25792. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  25793. * @param buffer defines a user defined buffer to fill with data (can be null)
  25794. * @returns The Array buffer containing the pixels data.
  25795. */
  25796. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  25797. /**
  25798. * Release and destroy the underlying lower level texture aka internalTexture.
  25799. */
  25800. releaseInternalTexture(): void;
  25801. /**
  25802. * Get the polynomial representation of the texture data.
  25803. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25804. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25805. */
  25806. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25807. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  25808. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  25809. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  25810. /**
  25811. * Dispose the texture and release its associated resources.
  25812. */
  25813. dispose(): void;
  25814. /**
  25815. * Serialize the texture into a JSON representation that can be parsed later on.
  25816. * @returns the JSON representation of the texture
  25817. */
  25818. serialize(): any;
  25819. /**
  25820. * Helper function to be called back once a list of texture contains only ready textures.
  25821. * @param textures Define the list of textures to wait for
  25822. * @param callback Define the callback triggered once the entire list will be ready
  25823. */
  25824. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  25825. }
  25826. }
  25827. declare module BABYLON {
  25828. /**
  25829. * Uniform buffer objects.
  25830. *
  25831. * Handles blocks of uniform on the GPU.
  25832. *
  25833. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25834. *
  25835. * For more information, please refer to :
  25836. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25837. */
  25838. export class UniformBuffer {
  25839. private _engine;
  25840. private _buffer;
  25841. private _data;
  25842. private _bufferData;
  25843. private _dynamic?;
  25844. private _uniformLocations;
  25845. private _uniformSizes;
  25846. private _uniformLocationPointer;
  25847. private _needSync;
  25848. private _noUBO;
  25849. private _currentEffect;
  25850. private static _MAX_UNIFORM_SIZE;
  25851. private static _tempBuffer;
  25852. /**
  25853. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  25854. * This is dynamic to allow compat with webgl 1 and 2.
  25855. * You will need to pass the name of the uniform as well as the value.
  25856. */
  25857. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  25858. /**
  25859. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  25860. * This is dynamic to allow compat with webgl 1 and 2.
  25861. * You will need to pass the name of the uniform as well as the value.
  25862. */
  25863. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  25864. /**
  25865. * Lambda to Update a single float in a uniform buffer.
  25866. * This is dynamic to allow compat with webgl 1 and 2.
  25867. * You will need to pass the name of the uniform as well as the value.
  25868. */
  25869. updateFloat: (name: string, x: number) => void;
  25870. /**
  25871. * Lambda to Update a vec2 of float in a uniform buffer.
  25872. * This is dynamic to allow compat with webgl 1 and 2.
  25873. * You will need to pass the name of the uniform as well as the value.
  25874. */
  25875. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  25876. /**
  25877. * Lambda to Update a vec3 of float in a uniform buffer.
  25878. * This is dynamic to allow compat with webgl 1 and 2.
  25879. * You will need to pass the name of the uniform as well as the value.
  25880. */
  25881. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  25882. /**
  25883. * Lambda to Update a vec4 of float in a uniform buffer.
  25884. * This is dynamic to allow compat with webgl 1 and 2.
  25885. * You will need to pass the name of the uniform as well as the value.
  25886. */
  25887. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  25888. /**
  25889. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  25890. * This is dynamic to allow compat with webgl 1 and 2.
  25891. * You will need to pass the name of the uniform as well as the value.
  25892. */
  25893. updateMatrix: (name: string, mat: Matrix) => void;
  25894. /**
  25895. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  25896. * This is dynamic to allow compat with webgl 1 and 2.
  25897. * You will need to pass the name of the uniform as well as the value.
  25898. */
  25899. updateVector3: (name: string, vector: Vector3) => void;
  25900. /**
  25901. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  25902. * This is dynamic to allow compat with webgl 1 and 2.
  25903. * You will need to pass the name of the uniform as well as the value.
  25904. */
  25905. updateVector4: (name: string, vector: Vector4) => void;
  25906. /**
  25907. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  25908. * This is dynamic to allow compat with webgl 1 and 2.
  25909. * You will need to pass the name of the uniform as well as the value.
  25910. */
  25911. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  25912. /**
  25913. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  25914. * This is dynamic to allow compat with webgl 1 and 2.
  25915. * You will need to pass the name of the uniform as well as the value.
  25916. */
  25917. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  25918. /**
  25919. * Instantiates a new Uniform buffer objects.
  25920. *
  25921. * Handles blocks of uniform on the GPU.
  25922. *
  25923. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  25924. *
  25925. * For more information, please refer to :
  25926. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  25927. * @param engine Define the engine the buffer is associated with
  25928. * @param data Define the data contained in the buffer
  25929. * @param dynamic Define if the buffer is updatable
  25930. */
  25931. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  25932. /**
  25933. * Indicates if the buffer is using the WebGL2 UBO implementation,
  25934. * or just falling back on setUniformXXX calls.
  25935. */
  25936. readonly useUbo: boolean;
  25937. /**
  25938. * Indicates if the WebGL underlying uniform buffer is in sync
  25939. * with the javascript cache data.
  25940. */
  25941. readonly isSync: boolean;
  25942. /**
  25943. * Indicates if the WebGL underlying uniform buffer is dynamic.
  25944. * Also, a dynamic UniformBuffer will disable cache verification and always
  25945. * update the underlying WebGL uniform buffer to the GPU.
  25946. * @returns if Dynamic, otherwise false
  25947. */
  25948. isDynamic(): boolean;
  25949. /**
  25950. * The data cache on JS side.
  25951. * @returns the underlying data as a float array
  25952. */
  25953. getData(): Float32Array;
  25954. /**
  25955. * The underlying WebGL Uniform buffer.
  25956. * @returns the webgl buffer
  25957. */
  25958. getBuffer(): Nullable<DataBuffer>;
  25959. /**
  25960. * std140 layout specifies how to align data within an UBO structure.
  25961. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  25962. * for specs.
  25963. */
  25964. private _fillAlignment;
  25965. /**
  25966. * Adds an uniform in the buffer.
  25967. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  25968. * for the layout to be correct !
  25969. * @param name Name of the uniform, as used in the uniform block in the shader.
  25970. * @param size Data size, or data directly.
  25971. */
  25972. addUniform(name: string, size: number | number[]): void;
  25973. /**
  25974. * Adds a Matrix 4x4 to the uniform buffer.
  25975. * @param name Name of the uniform, as used in the uniform block in the shader.
  25976. * @param mat A 4x4 matrix.
  25977. */
  25978. addMatrix(name: string, mat: Matrix): void;
  25979. /**
  25980. * Adds a vec2 to the uniform buffer.
  25981. * @param name Name of the uniform, as used in the uniform block in the shader.
  25982. * @param x Define the x component value of the vec2
  25983. * @param y Define the y component value of the vec2
  25984. */
  25985. addFloat2(name: string, x: number, y: number): void;
  25986. /**
  25987. * Adds a vec3 to the uniform buffer.
  25988. * @param name Name of the uniform, as used in the uniform block in the shader.
  25989. * @param x Define the x component value of the vec3
  25990. * @param y Define the y component value of the vec3
  25991. * @param z Define the z component value of the vec3
  25992. */
  25993. addFloat3(name: string, x: number, y: number, z: number): void;
  25994. /**
  25995. * Adds a vec3 to the uniform buffer.
  25996. * @param name Name of the uniform, as used in the uniform block in the shader.
  25997. * @param color Define the vec3 from a Color
  25998. */
  25999. addColor3(name: string, color: Color3): void;
  26000. /**
  26001. * Adds a vec4 to the uniform buffer.
  26002. * @param name Name of the uniform, as used in the uniform block in the shader.
  26003. * @param color Define the rgb components from a Color
  26004. * @param alpha Define the a component of the vec4
  26005. */
  26006. addColor4(name: string, color: Color3, alpha: number): void;
  26007. /**
  26008. * Adds a vec3 to the uniform buffer.
  26009. * @param name Name of the uniform, as used in the uniform block in the shader.
  26010. * @param vector Define the vec3 components from a Vector
  26011. */
  26012. addVector3(name: string, vector: Vector3): void;
  26013. /**
  26014. * Adds a Matrix 3x3 to the uniform buffer.
  26015. * @param name Name of the uniform, as used in the uniform block in the shader.
  26016. */
  26017. addMatrix3x3(name: string): void;
  26018. /**
  26019. * Adds a Matrix 2x2 to the uniform buffer.
  26020. * @param name Name of the uniform, as used in the uniform block in the shader.
  26021. */
  26022. addMatrix2x2(name: string): void;
  26023. /**
  26024. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26025. */
  26026. create(): void;
  26027. /** @hidden */ private _rebuild(): void;
  26028. /**
  26029. * Updates the WebGL Uniform Buffer on the GPU.
  26030. * If the `dynamic` flag is set to true, no cache comparison is done.
  26031. * Otherwise, the buffer will be updated only if the cache differs.
  26032. */
  26033. update(): void;
  26034. /**
  26035. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26036. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26037. * @param data Define the flattened data
  26038. * @param size Define the size of the data.
  26039. */
  26040. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26041. private _updateMatrix3x3ForUniform;
  26042. private _updateMatrix3x3ForEffect;
  26043. private _updateMatrix2x2ForEffect;
  26044. private _updateMatrix2x2ForUniform;
  26045. private _updateFloatForEffect;
  26046. private _updateFloatForUniform;
  26047. private _updateFloat2ForEffect;
  26048. private _updateFloat2ForUniform;
  26049. private _updateFloat3ForEffect;
  26050. private _updateFloat3ForUniform;
  26051. private _updateFloat4ForEffect;
  26052. private _updateFloat4ForUniform;
  26053. private _updateMatrixForEffect;
  26054. private _updateMatrixForUniform;
  26055. private _updateVector3ForEffect;
  26056. private _updateVector3ForUniform;
  26057. private _updateVector4ForEffect;
  26058. private _updateVector4ForUniform;
  26059. private _updateColor3ForEffect;
  26060. private _updateColor3ForUniform;
  26061. private _updateColor4ForEffect;
  26062. private _updateColor4ForUniform;
  26063. /**
  26064. * Sets a sampler uniform on the effect.
  26065. * @param name Define the name of the sampler.
  26066. * @param texture Define the texture to set in the sampler
  26067. */
  26068. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26069. /**
  26070. * Directly updates the value of the uniform in the cache AND on the GPU.
  26071. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26072. * @param data Define the flattened data
  26073. */
  26074. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26075. /**
  26076. * Binds this uniform buffer to an effect.
  26077. * @param effect Define the effect to bind the buffer to
  26078. * @param name Name of the uniform block in the shader.
  26079. */
  26080. bindToEffect(effect: Effect, name: string): void;
  26081. /**
  26082. * Disposes the uniform buffer.
  26083. */
  26084. dispose(): void;
  26085. }
  26086. }
  26087. declare module BABYLON {
  26088. /**
  26089. * Class used to work with sound analyzer using fast fourier transform (FFT)
  26090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26091. */
  26092. export class Analyser {
  26093. /**
  26094. * Gets or sets the smoothing
  26095. * @ignorenaming
  26096. */
  26097. SMOOTHING: number;
  26098. /**
  26099. * Gets or sets the FFT table size
  26100. * @ignorenaming
  26101. */
  26102. FFT_SIZE: number;
  26103. /**
  26104. * Gets or sets the bar graph amplitude
  26105. * @ignorenaming
  26106. */
  26107. BARGRAPHAMPLITUDE: number;
  26108. /**
  26109. * Gets or sets the position of the debug canvas
  26110. * @ignorenaming
  26111. */
  26112. DEBUGCANVASPOS: {
  26113. x: number;
  26114. y: number;
  26115. };
  26116. /**
  26117. * Gets or sets the debug canvas size
  26118. * @ignorenaming
  26119. */
  26120. DEBUGCANVASSIZE: {
  26121. width: number;
  26122. height: number;
  26123. };
  26124. private _byteFreqs;
  26125. private _byteTime;
  26126. private _floatFreqs;
  26127. private _webAudioAnalyser;
  26128. private _debugCanvas;
  26129. private _debugCanvasContext;
  26130. private _scene;
  26131. private _registerFunc;
  26132. private _audioEngine;
  26133. /**
  26134. * Creates a new analyser
  26135. * @param scene defines hosting scene
  26136. */
  26137. constructor(scene: Scene);
  26138. /**
  26139. * Get the number of data values you will have to play with for the visualization
  26140. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  26141. * @returns a number
  26142. */
  26143. getFrequencyBinCount(): number;
  26144. /**
  26145. * Gets the current frequency data as a byte array
  26146. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26147. * @returns a Uint8Array
  26148. */
  26149. getByteFrequencyData(): Uint8Array;
  26150. /**
  26151. * Gets the current waveform as a byte array
  26152. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  26153. * @returns a Uint8Array
  26154. */
  26155. getByteTimeDomainData(): Uint8Array;
  26156. /**
  26157. * Gets the current frequency data as a float array
  26158. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  26159. * @returns a Float32Array
  26160. */
  26161. getFloatFrequencyData(): Float32Array;
  26162. /**
  26163. * Renders the debug canvas
  26164. */
  26165. drawDebugCanvas(): void;
  26166. /**
  26167. * Stops rendering the debug canvas and removes it
  26168. */
  26169. stopDebugCanvas(): void;
  26170. /**
  26171. * Connects two audio nodes
  26172. * @param inputAudioNode defines first node to connect
  26173. * @param outputAudioNode defines second node to connect
  26174. */
  26175. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  26176. /**
  26177. * Releases all associated resources
  26178. */
  26179. dispose(): void;
  26180. }
  26181. }
  26182. declare module BABYLON {
  26183. /**
  26184. * This represents an audio engine and it is responsible
  26185. * to play, synchronize and analyse sounds throughout the application.
  26186. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26187. */
  26188. export interface IAudioEngine extends IDisposable {
  26189. /**
  26190. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26191. */
  26192. readonly canUseWebAudio: boolean;
  26193. /**
  26194. * Gets the current AudioContext if available.
  26195. */
  26196. readonly audioContext: Nullable<AudioContext>;
  26197. /**
  26198. * The master gain node defines the global audio volume of your audio engine.
  26199. */
  26200. readonly masterGain: GainNode;
  26201. /**
  26202. * Gets whether or not mp3 are supported by your browser.
  26203. */
  26204. readonly isMP3supported: boolean;
  26205. /**
  26206. * Gets whether or not ogg are supported by your browser.
  26207. */
  26208. readonly isOGGsupported: boolean;
  26209. /**
  26210. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26211. * @ignoreNaming
  26212. */
  26213. WarnedWebAudioUnsupported: boolean;
  26214. /**
  26215. * Defines if the audio engine relies on a custom unlocked button.
  26216. * In this case, the embedded button will not be displayed.
  26217. */
  26218. useCustomUnlockedButton: boolean;
  26219. /**
  26220. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  26221. */
  26222. readonly unlocked: boolean;
  26223. /**
  26224. * Event raised when audio has been unlocked on the browser.
  26225. */
  26226. onAudioUnlockedObservable: Observable<AudioEngine>;
  26227. /**
  26228. * Event raised when audio has been locked on the browser.
  26229. */
  26230. onAudioLockedObservable: Observable<AudioEngine>;
  26231. /**
  26232. * Flags the audio engine in Locked state.
  26233. * This happens due to new browser policies preventing audio to autoplay.
  26234. */
  26235. lock(): void;
  26236. /**
  26237. * Unlocks the audio engine once a user action has been done on the dom.
  26238. * This is helpful to resume play once browser policies have been satisfied.
  26239. */
  26240. unlock(): void;
  26241. }
  26242. /**
  26243. * This represents the default audio engine used in babylon.
  26244. * It is responsible to play, synchronize and analyse sounds throughout the application.
  26245. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26246. */
  26247. export class AudioEngine implements IAudioEngine {
  26248. private _audioContext;
  26249. private _audioContextInitialized;
  26250. private _muteButton;
  26251. private _hostElement;
  26252. /**
  26253. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  26254. */
  26255. canUseWebAudio: boolean;
  26256. /**
  26257. * The master gain node defines the global audio volume of your audio engine.
  26258. */
  26259. masterGain: GainNode;
  26260. /**
  26261. * Defines if Babylon should emit a warning if WebAudio is not supported.
  26262. * @ignoreNaming
  26263. */
  26264. WarnedWebAudioUnsupported: boolean;
  26265. /**
  26266. * Gets whether or not mp3 are supported by your browser.
  26267. */
  26268. isMP3supported: boolean;
  26269. /**
  26270. * Gets whether or not ogg are supported by your browser.
  26271. */
  26272. isOGGsupported: boolean;
  26273. /**
  26274. * Gets whether audio has been unlocked on the device.
  26275. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  26276. * a user interaction has happened.
  26277. */
  26278. unlocked: boolean;
  26279. /**
  26280. * Defines if the audio engine relies on a custom unlocked button.
  26281. * In this case, the embedded button will not be displayed.
  26282. */
  26283. useCustomUnlockedButton: boolean;
  26284. /**
  26285. * Event raised when audio has been unlocked on the browser.
  26286. */
  26287. onAudioUnlockedObservable: Observable<AudioEngine>;
  26288. /**
  26289. * Event raised when audio has been locked on the browser.
  26290. */
  26291. onAudioLockedObservable: Observable<AudioEngine>;
  26292. /**
  26293. * Gets the current AudioContext if available.
  26294. */
  26295. readonly audioContext: Nullable<AudioContext>;
  26296. private _connectedAnalyser;
  26297. /**
  26298. * Instantiates a new audio engine.
  26299. *
  26300. * There should be only one per page as some browsers restrict the number
  26301. * of audio contexts you can create.
  26302. * @param hostElement defines the host element where to display the mute icon if necessary
  26303. */
  26304. constructor(hostElement?: Nullable<HTMLElement>);
  26305. /**
  26306. * Flags the audio engine in Locked state.
  26307. * This happens due to new browser policies preventing audio to autoplay.
  26308. */
  26309. lock(): void;
  26310. /**
  26311. * Unlocks the audio engine once a user action has been done on the dom.
  26312. * This is helpful to resume play once browser policies have been satisfied.
  26313. */
  26314. unlock(): void;
  26315. private _resumeAudioContext;
  26316. private _initializeAudioContext;
  26317. private _tryToRun;
  26318. private _triggerRunningState;
  26319. private _triggerSuspendedState;
  26320. private _displayMuteButton;
  26321. private _moveButtonToTopLeft;
  26322. private _onResize;
  26323. private _hideMuteButton;
  26324. /**
  26325. * Destroy and release the resources associated with the audio ccontext.
  26326. */
  26327. dispose(): void;
  26328. /**
  26329. * Gets the global volume sets on the master gain.
  26330. * @returns the global volume if set or -1 otherwise
  26331. */
  26332. getGlobalVolume(): number;
  26333. /**
  26334. * Sets the global volume of your experience (sets on the master gain).
  26335. * @param newVolume Defines the new global volume of the application
  26336. */
  26337. setGlobalVolume(newVolume: number): void;
  26338. /**
  26339. * Connect the audio engine to an audio analyser allowing some amazing
  26340. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  26341. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  26342. * @param analyser The analyser to connect to the engine
  26343. */
  26344. connectToAnalyser(analyser: Analyser): void;
  26345. }
  26346. }
  26347. declare module BABYLON {
  26348. /**
  26349. * Interface used to present a loading screen while loading a scene
  26350. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26351. */
  26352. export interface ILoadingScreen {
  26353. /**
  26354. * Function called to display the loading screen
  26355. */
  26356. displayLoadingUI: () => void;
  26357. /**
  26358. * Function called to hide the loading screen
  26359. */
  26360. hideLoadingUI: () => void;
  26361. /**
  26362. * Gets or sets the color to use for the background
  26363. */
  26364. loadingUIBackgroundColor: string;
  26365. /**
  26366. * Gets or sets the text to display while loading
  26367. */
  26368. loadingUIText: string;
  26369. }
  26370. /**
  26371. * Class used for the default loading screen
  26372. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  26373. */
  26374. export class DefaultLoadingScreen implements ILoadingScreen {
  26375. private _renderingCanvas;
  26376. private _loadingText;
  26377. private _loadingDivBackgroundColor;
  26378. private _loadingDiv;
  26379. private _loadingTextDiv;
  26380. /** Gets or sets the logo url to use for the default loading screen */
  26381. static DefaultLogoUrl: string;
  26382. /** Gets or sets the spinner url to use for the default loading screen */
  26383. static DefaultSpinnerUrl: string;
  26384. /**
  26385. * Creates a new default loading screen
  26386. * @param _renderingCanvas defines the canvas used to render the scene
  26387. * @param _loadingText defines the default text to display
  26388. * @param _loadingDivBackgroundColor defines the default background color
  26389. */
  26390. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  26391. /**
  26392. * Function called to display the loading screen
  26393. */
  26394. displayLoadingUI(): void;
  26395. /**
  26396. * Function called to hide the loading screen
  26397. */
  26398. hideLoadingUI(): void;
  26399. /**
  26400. * Gets or sets the text to display while loading
  26401. */
  26402. loadingUIText: string;
  26403. /**
  26404. * Gets or sets the color to use for the background
  26405. */
  26406. loadingUIBackgroundColor: string;
  26407. private _resizeLoadingUI;
  26408. }
  26409. }
  26410. declare module BABYLON {
  26411. /** @hidden */
  26412. export class WebGLPipelineContext implements IPipelineContext {
  26413. engine: Engine;
  26414. program: Nullable<WebGLProgram>;
  26415. context?: WebGLRenderingContext;
  26416. vertexShader?: WebGLShader;
  26417. fragmentShader?: WebGLShader;
  26418. isParallelCompiled: boolean;
  26419. onCompiled?: () => void;
  26420. transformFeedback?: WebGLTransformFeedback | null;
  26421. readonly isAsync: boolean;
  26422. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  26423. }
  26424. }
  26425. declare module BABYLON {
  26426. /** @hidden */
  26427. export class WebGLDataBuffer extends DataBuffer {
  26428. private _buffer;
  26429. constructor(resource: WebGLBuffer);
  26430. readonly underlyingResource: any;
  26431. }
  26432. }
  26433. declare module BABYLON {
  26434. /**
  26435. * Settings for finer control over video usage
  26436. */
  26437. export interface VideoTextureSettings {
  26438. /**
  26439. * Applies `autoplay` to video, if specified
  26440. */
  26441. autoPlay?: boolean;
  26442. /**
  26443. * Applies `loop` to video, if specified
  26444. */
  26445. loop?: boolean;
  26446. /**
  26447. * Automatically updates internal texture from video at every frame in the render loop
  26448. */
  26449. autoUpdateTexture: boolean;
  26450. /**
  26451. * Image src displayed during the video loading or until the user interacts with the video.
  26452. */
  26453. poster?: string;
  26454. }
  26455. /**
  26456. * If you want to display a video in your scene, this is the special texture for that.
  26457. * This special texture works similar to other textures, with the exception of a few parameters.
  26458. * @see https://doc.babylonjs.com/how_to/video_texture
  26459. */
  26460. export class VideoTexture extends Texture {
  26461. /**
  26462. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  26463. */
  26464. readonly autoUpdateTexture: boolean;
  26465. /**
  26466. * The video instance used by the texture internally
  26467. */
  26468. readonly video: HTMLVideoElement;
  26469. private _onUserActionRequestedObservable;
  26470. /**
  26471. * Event triggerd when a dom action is required by the user to play the video.
  26472. * This happens due to recent changes in browser policies preventing video to auto start.
  26473. */
  26474. readonly onUserActionRequestedObservable: Observable<Texture>;
  26475. private _generateMipMaps;
  26476. private _engine;
  26477. private _stillImageCaptured;
  26478. private _displayingPosterTexture;
  26479. private _settings;
  26480. private _createInternalTextureOnEvent;
  26481. /**
  26482. * Creates a video texture.
  26483. * If you want to display a video in your scene, this is the special texture for that.
  26484. * This special texture works similar to other textures, with the exception of a few parameters.
  26485. * @see https://doc.babylonjs.com/how_to/video_texture
  26486. * @param name optional name, will detect from video source, if not defined
  26487. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  26488. * @param scene is obviously the current scene.
  26489. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  26490. * @param invertY is false by default but can be used to invert video on Y axis
  26491. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  26492. * @param settings allows finer control over video usage
  26493. */
  26494. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  26495. private _getName;
  26496. private _getVideo;
  26497. private _createInternalTexture;
  26498. private reset;
  26499. /**
  26500. * @hidden Internal method to initiate `update`.
  26501. */ private _rebuild(): void;
  26502. /**
  26503. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  26504. */
  26505. update(): void;
  26506. /**
  26507. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  26508. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  26509. */
  26510. updateTexture(isVisible: boolean): void;
  26511. protected _updateInternalTexture: () => void;
  26512. /**
  26513. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  26514. * @param url New url.
  26515. */
  26516. updateURL(url: string): void;
  26517. /**
  26518. * Dispose the texture and release its associated resources.
  26519. */
  26520. dispose(): void;
  26521. /**
  26522. * Creates a video texture straight from a stream.
  26523. * @param scene Define the scene the texture should be created in
  26524. * @param stream Define the stream the texture should be created from
  26525. * @returns The created video texture as a promise
  26526. */
  26527. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  26528. /**
  26529. * Creates a video texture straight from your WebCam video feed.
  26530. * @param scene Define the scene the texture should be created in
  26531. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26532. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26533. * @returns The created video texture as a promise
  26534. */
  26535. static CreateFromWebCamAsync(scene: Scene, constraints: {
  26536. minWidth: number;
  26537. maxWidth: number;
  26538. minHeight: number;
  26539. maxHeight: number;
  26540. deviceId: string;
  26541. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  26542. /**
  26543. * Creates a video texture straight from your WebCam video feed.
  26544. * @param scene Define the scene the texture should be created in
  26545. * @param onReady Define a callback to triggered once the texture will be ready
  26546. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  26547. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  26548. */
  26549. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  26550. minWidth: number;
  26551. maxWidth: number;
  26552. minHeight: number;
  26553. maxHeight: number;
  26554. deviceId: string;
  26555. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  26556. }
  26557. }
  26558. declare module BABYLON {
  26559. /**
  26560. * Interface for attribute information associated with buffer instanciation
  26561. */
  26562. export class InstancingAttributeInfo {
  26563. /**
  26564. * Index/offset of the attribute in the vertex shader
  26565. */
  26566. index: number;
  26567. /**
  26568. * size of the attribute, 1, 2, 3 or 4
  26569. */
  26570. attributeSize: number;
  26571. /**
  26572. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  26573. * default is FLOAT
  26574. */
  26575. attribyteType: number;
  26576. /**
  26577. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  26578. */
  26579. normalized: boolean;
  26580. /**
  26581. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  26582. */
  26583. offset: number;
  26584. /**
  26585. * Name of the GLSL attribute, for debugging purpose only
  26586. */
  26587. attributeName: string;
  26588. }
  26589. /**
  26590. * Define options used to create a depth texture
  26591. */
  26592. export class DepthTextureCreationOptions {
  26593. /** Specifies whether or not a stencil should be allocated in the texture */
  26594. generateStencil?: boolean;
  26595. /** Specifies whether or not bilinear filtering is enable on the texture */
  26596. bilinearFiltering?: boolean;
  26597. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  26598. comparisonFunction?: number;
  26599. /** Specifies if the created texture is a cube texture */
  26600. isCube?: boolean;
  26601. }
  26602. /**
  26603. * Class used to describe the capabilities of the engine relatively to the current browser
  26604. */
  26605. export class EngineCapabilities {
  26606. /** Maximum textures units per fragment shader */
  26607. maxTexturesImageUnits: number;
  26608. /** Maximum texture units per vertex shader */
  26609. maxVertexTextureImageUnits: number;
  26610. /** Maximum textures units in the entire pipeline */
  26611. maxCombinedTexturesImageUnits: number;
  26612. /** Maximum texture size */
  26613. maxTextureSize: number;
  26614. /** Maximum cube texture size */
  26615. maxCubemapTextureSize: number;
  26616. /** Maximum render texture size */
  26617. maxRenderTextureSize: number;
  26618. /** Maximum number of vertex attributes */
  26619. maxVertexAttribs: number;
  26620. /** Maximum number of varyings */
  26621. maxVaryingVectors: number;
  26622. /** Maximum number of uniforms per vertex shader */
  26623. maxVertexUniformVectors: number;
  26624. /** Maximum number of uniforms per fragment shader */
  26625. maxFragmentUniformVectors: number;
  26626. /** Defines if standard derivates (dx/dy) are supported */
  26627. standardDerivatives: boolean;
  26628. /** Defines if s3tc texture compression is supported */
  26629. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  26630. /** Defines if pvrtc texture compression is supported */
  26631. pvrtc: any;
  26632. /** Defines if etc1 texture compression is supported */
  26633. etc1: any;
  26634. /** Defines if etc2 texture compression is supported */
  26635. etc2: any;
  26636. /** Defines if astc texture compression is supported */
  26637. astc: any;
  26638. /** Defines if float textures are supported */
  26639. textureFloat: boolean;
  26640. /** Defines if vertex array objects are supported */
  26641. vertexArrayObject: boolean;
  26642. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  26643. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  26644. /** Gets the maximum level of anisotropy supported */
  26645. maxAnisotropy: number;
  26646. /** Defines if instancing is supported */
  26647. instancedArrays: boolean;
  26648. /** Defines if 32 bits indices are supported */
  26649. uintIndices: boolean;
  26650. /** Defines if high precision shaders are supported */
  26651. highPrecisionShaderSupported: boolean;
  26652. /** Defines if depth reading in the fragment shader is supported */
  26653. fragmentDepthSupported: boolean;
  26654. /** Defines if float texture linear filtering is supported*/
  26655. textureFloatLinearFiltering: boolean;
  26656. /** Defines if rendering to float textures is supported */
  26657. textureFloatRender: boolean;
  26658. /** Defines if half float textures are supported*/
  26659. textureHalfFloat: boolean;
  26660. /** Defines if half float texture linear filtering is supported*/
  26661. textureHalfFloatLinearFiltering: boolean;
  26662. /** Defines if rendering to half float textures is supported */
  26663. textureHalfFloatRender: boolean;
  26664. /** Defines if textureLOD shader command is supported */
  26665. textureLOD: boolean;
  26666. /** Defines if draw buffers extension is supported */
  26667. drawBuffersExtension: boolean;
  26668. /** Defines if depth textures are supported */
  26669. depthTextureExtension: boolean;
  26670. /** Defines if float color buffer are supported */
  26671. colorBufferFloat: boolean;
  26672. /** Gets disjoint timer query extension (null if not supported) */
  26673. timerQuery: EXT_disjoint_timer_query;
  26674. /** Defines if timestamp can be used with timer query */
  26675. canUseTimestampForTimerQuery: boolean;
  26676. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  26677. multiview: any;
  26678. /** Function used to let the system compiles shaders in background */
  26679. parallelShaderCompile: {
  26680. COMPLETION_STATUS_KHR: number;
  26681. };
  26682. }
  26683. /** Interface defining initialization parameters for Engine class */
  26684. export interface EngineOptions extends WebGLContextAttributes {
  26685. /**
  26686. * Defines if the engine should no exceed a specified device ratio
  26687. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  26688. */
  26689. limitDeviceRatio?: number;
  26690. /**
  26691. * Defines if webvr should be enabled automatically
  26692. * @see http://doc.babylonjs.com/how_to/webvr_camera
  26693. */
  26694. autoEnableWebVR?: boolean;
  26695. /**
  26696. * Defines if webgl2 should be turned off even if supported
  26697. * @see http://doc.babylonjs.com/features/webgl2
  26698. */
  26699. disableWebGL2Support?: boolean;
  26700. /**
  26701. * Defines if webaudio should be initialized as well
  26702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  26703. */
  26704. audioEngine?: boolean;
  26705. /**
  26706. * Defines if animations should run using a deterministic lock step
  26707. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  26708. */
  26709. deterministicLockstep?: boolean;
  26710. /** Defines the maximum steps to use with deterministic lock step mode */
  26711. lockstepMaxSteps?: number;
  26712. /**
  26713. * Defines that engine should ignore context lost events
  26714. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  26715. */
  26716. doNotHandleContextLost?: boolean;
  26717. /**
  26718. * Defines that engine should ignore modifying touch action attribute and style
  26719. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  26720. */
  26721. doNotHandleTouchAction?: boolean;
  26722. /**
  26723. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  26724. */
  26725. useHighPrecisionFloats?: boolean;
  26726. }
  26727. /**
  26728. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  26729. */
  26730. export class Engine {
  26731. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  26732. static ExceptionList: ({
  26733. key: string;
  26734. capture: string;
  26735. captureConstraint: number;
  26736. targets: string[];
  26737. } | {
  26738. key: string;
  26739. capture: null;
  26740. captureConstraint: null;
  26741. targets: string[];
  26742. })[];
  26743. /** Gets the list of created engines */
  26744. static readonly Instances: Engine[];
  26745. /**
  26746. * Gets the latest created engine
  26747. */
  26748. static readonly LastCreatedEngine: Nullable<Engine>;
  26749. /**
  26750. * Gets the latest created scene
  26751. */
  26752. static readonly LastCreatedScene: Nullable<Scene>;
  26753. /**
  26754. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  26755. * @param flag defines which part of the materials must be marked as dirty
  26756. * @param predicate defines a predicate used to filter which materials should be affected
  26757. */
  26758. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  26759. /**
  26760. * Hidden
  26761. */ private static _TextureLoaders: IInternalTextureLoader[];
  26762. /** Defines that alpha blending is disabled */
  26763. static readonly ALPHA_DISABLE: number;
  26764. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  26765. static readonly ALPHA_ADD: number;
  26766. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  26767. static readonly ALPHA_COMBINE: number;
  26768. /** Defines that alpha blending to DEST - SRC * DEST */
  26769. static readonly ALPHA_SUBTRACT: number;
  26770. /** Defines that alpha blending to SRC * DEST */
  26771. static readonly ALPHA_MULTIPLY: number;
  26772. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  26773. static readonly ALPHA_MAXIMIZED: number;
  26774. /** Defines that alpha blending to SRC + DEST */
  26775. static readonly ALPHA_ONEONE: number;
  26776. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  26777. static readonly ALPHA_PREMULTIPLIED: number;
  26778. /**
  26779. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  26780. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  26781. */
  26782. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  26783. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  26784. static readonly ALPHA_INTERPOLATE: number;
  26785. /**
  26786. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  26787. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  26788. */
  26789. static readonly ALPHA_SCREENMODE: number;
  26790. /** Defines that the ressource is not delayed*/
  26791. static readonly DELAYLOADSTATE_NONE: number;
  26792. /** Defines that the ressource was successfully delay loaded */
  26793. static readonly DELAYLOADSTATE_LOADED: number;
  26794. /** Defines that the ressource is currently delay loading */
  26795. static readonly DELAYLOADSTATE_LOADING: number;
  26796. /** Defines that the ressource is delayed and has not started loading */
  26797. static readonly DELAYLOADSTATE_NOTLOADED: number;
  26798. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  26799. static readonly NEVER: number;
  26800. /** 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 */
  26801. static readonly ALWAYS: number;
  26802. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  26803. static readonly LESS: number;
  26804. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  26805. static readonly EQUAL: number;
  26806. /** 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 */
  26807. static readonly LEQUAL: number;
  26808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  26809. static readonly GREATER: number;
  26810. /** 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 */
  26811. static readonly GEQUAL: number;
  26812. /** 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 */
  26813. static readonly NOTEQUAL: number;
  26814. /** Passed to stencilOperation to specify that stencil value must be kept */
  26815. static readonly KEEP: number;
  26816. /** Passed to stencilOperation to specify that stencil value must be replaced */
  26817. static readonly REPLACE: number;
  26818. /** Passed to stencilOperation to specify that stencil value must be incremented */
  26819. static readonly INCR: number;
  26820. /** Passed to stencilOperation to specify that stencil value must be decremented */
  26821. static readonly DECR: number;
  26822. /** Passed to stencilOperation to specify that stencil value must be inverted */
  26823. static readonly INVERT: number;
  26824. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  26825. static readonly INCR_WRAP: number;
  26826. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  26827. static readonly DECR_WRAP: number;
  26828. /** Texture is not repeating outside of 0..1 UVs */
  26829. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  26830. /** Texture is repeating outside of 0..1 UVs */
  26831. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  26832. /** Texture is repeating and mirrored */
  26833. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  26834. /** ALPHA */
  26835. static readonly TEXTUREFORMAT_ALPHA: number;
  26836. /** LUMINANCE */
  26837. static readonly TEXTUREFORMAT_LUMINANCE: number;
  26838. /** LUMINANCE_ALPHA */
  26839. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  26840. /** RGB */
  26841. static readonly TEXTUREFORMAT_RGB: number;
  26842. /** RGBA */
  26843. static readonly TEXTUREFORMAT_RGBA: number;
  26844. /** RED */
  26845. static readonly TEXTUREFORMAT_RED: number;
  26846. /** RED (2nd reference) */
  26847. static readonly TEXTUREFORMAT_R: number;
  26848. /** RG */
  26849. static readonly TEXTUREFORMAT_RG: number;
  26850. /** RED_INTEGER */
  26851. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  26852. /** RED_INTEGER (2nd reference) */
  26853. static readonly TEXTUREFORMAT_R_INTEGER: number;
  26854. /** RG_INTEGER */
  26855. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  26856. /** RGB_INTEGER */
  26857. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  26858. /** RGBA_INTEGER */
  26859. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  26860. /** UNSIGNED_BYTE */
  26861. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  26862. /** UNSIGNED_BYTE (2nd reference) */
  26863. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  26864. /** FLOAT */
  26865. static readonly TEXTURETYPE_FLOAT: number;
  26866. /** HALF_FLOAT */
  26867. static readonly TEXTURETYPE_HALF_FLOAT: number;
  26868. /** BYTE */
  26869. static readonly TEXTURETYPE_BYTE: number;
  26870. /** SHORT */
  26871. static readonly TEXTURETYPE_SHORT: number;
  26872. /** UNSIGNED_SHORT */
  26873. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  26874. /** INT */
  26875. static readonly TEXTURETYPE_INT: number;
  26876. /** UNSIGNED_INT */
  26877. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  26878. /** UNSIGNED_SHORT_4_4_4_4 */
  26879. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  26880. /** UNSIGNED_SHORT_5_5_5_1 */
  26881. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  26882. /** UNSIGNED_SHORT_5_6_5 */
  26883. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  26884. /** UNSIGNED_INT_2_10_10_10_REV */
  26885. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  26886. /** UNSIGNED_INT_24_8 */
  26887. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  26888. /** UNSIGNED_INT_10F_11F_11F_REV */
  26889. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  26890. /** UNSIGNED_INT_5_9_9_9_REV */
  26891. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  26892. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  26893. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  26894. /** nearest is mag = nearest and min = nearest and mip = linear */
  26895. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  26896. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26897. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  26898. /** Trilinear is mag = linear and min = linear and mip = linear */
  26899. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  26900. /** nearest is mag = nearest and min = nearest and mip = linear */
  26901. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  26902. /** Bilinear is mag = linear and min = linear and mip = nearest */
  26903. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  26904. /** Trilinear is mag = linear and min = linear and mip = linear */
  26905. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  26906. /** mag = nearest and min = nearest and mip = nearest */
  26907. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  26908. /** mag = nearest and min = linear and mip = nearest */
  26909. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  26910. /** mag = nearest and min = linear and mip = linear */
  26911. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  26912. /** mag = nearest and min = linear and mip = none */
  26913. static readonly TEXTURE_NEAREST_LINEAR: number;
  26914. /** mag = nearest and min = nearest and mip = none */
  26915. static readonly TEXTURE_NEAREST_NEAREST: number;
  26916. /** mag = linear and min = nearest and mip = nearest */
  26917. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  26918. /** mag = linear and min = nearest and mip = linear */
  26919. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  26920. /** mag = linear and min = linear and mip = none */
  26921. static readonly TEXTURE_LINEAR_LINEAR: number;
  26922. /** mag = linear and min = nearest and mip = none */
  26923. static readonly TEXTURE_LINEAR_NEAREST: number;
  26924. /** Explicit coordinates mode */
  26925. static readonly TEXTURE_EXPLICIT_MODE: number;
  26926. /** Spherical coordinates mode */
  26927. static readonly TEXTURE_SPHERICAL_MODE: number;
  26928. /** Planar coordinates mode */
  26929. static readonly TEXTURE_PLANAR_MODE: number;
  26930. /** Cubic coordinates mode */
  26931. static readonly TEXTURE_CUBIC_MODE: number;
  26932. /** Projection coordinates mode */
  26933. static readonly TEXTURE_PROJECTION_MODE: number;
  26934. /** Skybox coordinates mode */
  26935. static readonly TEXTURE_SKYBOX_MODE: number;
  26936. /** Inverse Cubic coordinates mode */
  26937. static readonly TEXTURE_INVCUBIC_MODE: number;
  26938. /** Equirectangular coordinates mode */
  26939. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  26940. /** Equirectangular Fixed coordinates mode */
  26941. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  26942. /** Equirectangular Fixed Mirrored coordinates mode */
  26943. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  26944. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  26945. static readonly SCALEMODE_FLOOR: number;
  26946. /** Defines that texture rescaling will look for the nearest power of 2 size */
  26947. static readonly SCALEMODE_NEAREST: number;
  26948. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  26949. static readonly SCALEMODE_CEILING: number;
  26950. /**
  26951. * Returns the current npm package of the sdk
  26952. */
  26953. static readonly NpmPackage: string;
  26954. /**
  26955. * Returns the current version of the framework
  26956. */
  26957. static readonly Version: string;
  26958. /**
  26959. * Returns a string describing the current engine
  26960. */
  26961. readonly description: string;
  26962. /**
  26963. * Gets or sets the epsilon value used by collision engine
  26964. */
  26965. static CollisionsEpsilon: number;
  26966. /**
  26967. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  26968. */
  26969. static ShadersRepository: string;
  26970. /**
  26971. * Method called to create the default loading screen.
  26972. * This can be overriden in your own app.
  26973. * @param canvas The rendering canvas element
  26974. * @returns The loading screen
  26975. */
  26976. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  26977. /**
  26978. * Method called to create the default rescale post process on each engine.
  26979. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  26980. /**
  26981. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  26982. */
  26983. forcePOTTextures: boolean;
  26984. /**
  26985. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  26986. */
  26987. isFullscreen: boolean;
  26988. /**
  26989. * Gets a boolean indicating if the pointer is currently locked
  26990. */
  26991. isPointerLock: boolean;
  26992. /**
  26993. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  26994. */
  26995. cullBackFaces: boolean;
  26996. /**
  26997. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  26998. */
  26999. renderEvenInBackground: boolean;
  27000. /**
  27001. * Gets or sets a boolean indicating that cache can be kept between frames
  27002. */
  27003. preventCacheWipeBetweenFrames: boolean;
  27004. /**
  27005. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27006. **/
  27007. enableOfflineSupport: boolean;
  27008. /**
  27009. * 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)
  27010. **/
  27011. disableManifestCheck: boolean;
  27012. /**
  27013. * Gets the list of created scenes
  27014. */
  27015. scenes: Scene[];
  27016. /**
  27017. * Event raised when a new scene is created
  27018. */
  27019. onNewSceneAddedObservable: Observable<Scene>;
  27020. /**
  27021. * Gets the list of created postprocesses
  27022. */
  27023. postProcesses: PostProcess[];
  27024. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27025. validateShaderPrograms: boolean;
  27026. /**
  27027. * Observable event triggered each time the rendering canvas is resized
  27028. */
  27029. onResizeObservable: Observable<Engine>;
  27030. /**
  27031. * Observable event triggered each time the canvas loses focus
  27032. */
  27033. onCanvasBlurObservable: Observable<Engine>;
  27034. /**
  27035. * Observable event triggered each time the canvas gains focus
  27036. */
  27037. onCanvasFocusObservable: Observable<Engine>;
  27038. /**
  27039. * Observable event triggered each time the canvas receives pointerout event
  27040. */
  27041. onCanvasPointerOutObservable: Observable<PointerEvent>;
  27042. /**
  27043. * Observable event triggered before each texture is initialized
  27044. */
  27045. onBeforeTextureInitObservable: Observable<Texture>;
  27046. /**
  27047. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27048. */
  27049. disableUniformBuffers: boolean;
  27050. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  27051. /**
  27052. * Gets a boolean indicating that the engine supports uniform buffers
  27053. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27054. */
  27055. readonly supportsUniformBuffers: boolean;
  27056. /**
  27057. * Observable raised when the engine begins a new frame
  27058. */
  27059. onBeginFrameObservable: Observable<Engine>;
  27060. /**
  27061. * If set, will be used to request the next animation frame for the render loop
  27062. */
  27063. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  27064. /**
  27065. * Observable raised when the engine ends the current frame
  27066. */
  27067. onEndFrameObservable: Observable<Engine>;
  27068. /**
  27069. * Observable raised when the engine is about to compile a shader
  27070. */
  27071. onBeforeShaderCompilationObservable: Observable<Engine>;
  27072. /**
  27073. * Observable raised when the engine has jsut compiled a shader
  27074. */
  27075. onAfterShaderCompilationObservable: Observable<Engine>;
  27076. /** @hidden */ private _gl: WebGLRenderingContext;
  27077. private _renderingCanvas;
  27078. private _windowIsBackground;
  27079. private _webGLVersion;
  27080. protected _highPrecisionShadersAllowed: boolean;
  27081. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  27082. /**
  27083. * Gets a boolean indicating that only power of 2 textures are supported
  27084. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  27085. */
  27086. readonly needPOTTextures: boolean;
  27087. /** @hidden */ private _badOS: boolean;
  27088. /** @hidden */ private _badDesktopOS: boolean;
  27089. /**
  27090. * Gets the audio engine
  27091. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27092. * @ignorenaming
  27093. */
  27094. static audioEngine: IAudioEngine;
  27095. /**
  27096. * Default AudioEngine factory responsible of creating the Audio Engine.
  27097. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  27098. */
  27099. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  27100. /**
  27101. * Default offline support factory responsible of creating a tool used to store data locally.
  27102. * By default, this will create a Database object if the workload has been embedded.
  27103. */
  27104. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  27105. private _onFocus;
  27106. private _onBlur;
  27107. private _onCanvasPointerOut;
  27108. private _onCanvasBlur;
  27109. private _onCanvasFocus;
  27110. private _onFullscreenChange;
  27111. private _onPointerLockChange;
  27112. private _hardwareScalingLevel;
  27113. /** @hidden */ private _caps: EngineCapabilities;
  27114. private _pointerLockRequested;
  27115. private _isStencilEnable;
  27116. private _colorWrite;
  27117. private _loadingScreen;
  27118. /** @hidden */ private _drawCalls: PerfCounter;
  27119. private _glVersion;
  27120. private _glRenderer;
  27121. private _glVendor;
  27122. private _videoTextureSupported;
  27123. private _renderingQueueLaunched;
  27124. private _activeRenderLoops;
  27125. private _deterministicLockstep;
  27126. private _lockstepMaxSteps;
  27127. /**
  27128. * Observable signaled when a context lost event is raised
  27129. */
  27130. onContextLostObservable: Observable<Engine>;
  27131. /**
  27132. * Observable signaled when a context restored event is raised
  27133. */
  27134. onContextRestoredObservable: Observable<Engine>;
  27135. private _onContextLost;
  27136. private _onContextRestored;
  27137. private _contextWasLost;
  27138. /** @hidden */ private _doNotHandleContextLost: boolean;
  27139. /**
  27140. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  27141. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  27142. */
  27143. doNotHandleContextLost: boolean;
  27144. private _performanceMonitor;
  27145. private _fps;
  27146. private _deltaTime;
  27147. /**
  27148. * Turn this value on if you want to pause FPS computation when in background
  27149. */
  27150. disablePerformanceMonitorInBackground: boolean;
  27151. /**
  27152. * Gets the performance monitor attached to this engine
  27153. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  27154. */
  27155. readonly performanceMonitor: PerformanceMonitor;
  27156. /**
  27157. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  27158. */
  27159. disableVertexArrayObjects: boolean;
  27160. /** @hidden */
  27161. protected _depthCullingState: _DepthCullingState;
  27162. /** @hidden */
  27163. protected _stencilState: _StencilState;
  27164. /** @hidden */
  27165. protected _alphaState: _AlphaState;
  27166. /** @hidden */
  27167. protected _alphaMode: number;
  27168. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  27169. /** @hidden */
  27170. protected _activeChannel: number;
  27171. private _currentTextureChannel;
  27172. /** @hidden */
  27173. protected _boundTexturesCache: {
  27174. [key: string]: Nullable<InternalTexture>;
  27175. };
  27176. /** @hidden */
  27177. protected _currentEffect: Nullable<Effect>;
  27178. /** @hidden */
  27179. protected _currentProgram: Nullable<WebGLProgram>;
  27180. private _compiledEffects;
  27181. private _vertexAttribArraysEnabled;
  27182. /** @hidden */
  27183. protected _cachedViewport: Nullable<Viewport>;
  27184. private _cachedVertexArrayObject;
  27185. /** @hidden */
  27186. protected _cachedVertexBuffers: any;
  27187. /** @hidden */
  27188. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  27189. /** @hidden */
  27190. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  27191. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  27192. private _uintIndicesCurrentlySet;
  27193. private _currentBoundBuffer;
  27194. /** @hidden */
  27195. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  27196. private _currentBufferPointers;
  27197. private _currentInstanceLocations;
  27198. private _currentInstanceBuffers;
  27199. private _textureUnits;
  27200. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27201. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27202. private _rescalePostProcess;
  27203. private _dummyFramebuffer;
  27204. private _externalData;
  27205. /** @hidden */ private _bindedRenderFunction: any;
  27206. private _vaoRecordInProgress;
  27207. private _mustWipeVertexAttributes;
  27208. private _emptyTexture;
  27209. private _emptyCubeTexture;
  27210. private _emptyTexture3D;
  27211. /** @hidden */ private _frameHandler: number;
  27212. private _nextFreeTextureSlots;
  27213. private _maxSimultaneousTextures;
  27214. private _activeRequests;
  27215. private _texturesSupported;
  27216. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  27217. /**
  27218. * Gets the list of texture formats supported
  27219. */
  27220. readonly texturesSupported: Array<string>;
  27221. /**
  27222. * Gets the list of texture formats in use
  27223. */
  27224. readonly textureFormatInUse: Nullable<string>;
  27225. /**
  27226. * Gets the current viewport
  27227. */
  27228. readonly currentViewport: Nullable<Viewport>;
  27229. /**
  27230. * Gets the default empty texture
  27231. */
  27232. readonly emptyTexture: InternalTexture;
  27233. /**
  27234. * Gets the default empty 3D texture
  27235. */
  27236. readonly emptyTexture3D: InternalTexture;
  27237. /**
  27238. * Gets the default empty cube texture
  27239. */
  27240. readonly emptyCubeTexture: InternalTexture;
  27241. /**
  27242. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27243. */
  27244. readonly premultipliedAlpha: boolean;
  27245. /**
  27246. * Creates a new engine
  27247. * @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
  27248. * @param antialias defines enable antialiasing (default: false)
  27249. * @param options defines further options to be sent to the getContext() function
  27250. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27251. */
  27252. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  27253. /**
  27254. * Initializes a webVR display and starts listening to display change events
  27255. * The onVRDisplayChangedObservable will be notified upon these changes
  27256. * @returns The onVRDisplayChangedObservable
  27257. */
  27258. initWebVR(): Observable<IDisplayChangedEventArgs>;
  27259. /** @hidden */ private _prepareVRComponent(): void;
  27260. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  27261. /** @hidden */ private _submitVRFrame(): void;
  27262. /**
  27263. * Call this function to leave webVR mode
  27264. * Will do nothing if webVR is not supported or if there is no webVR device
  27265. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27266. */
  27267. disableVR(): void;
  27268. /**
  27269. * Gets a boolean indicating that the system is in VR mode and is presenting
  27270. * @returns true if VR mode is engaged
  27271. */
  27272. isVRPresenting(): boolean;
  27273. /** @hidden */ private _requestVRFrame(): void;
  27274. private _disableTouchAction;
  27275. private _rebuildInternalTextures;
  27276. private _rebuildEffects;
  27277. /**
  27278. * Gets a boolean indicating if all created effects are ready
  27279. * @returns true if all effects are ready
  27280. */
  27281. areAllEffectsReady(): boolean;
  27282. private _rebuildBuffers;
  27283. private _initGLContext;
  27284. /**
  27285. * Gets version of the current webGL context
  27286. */
  27287. readonly webGLVersion: number;
  27288. /**
  27289. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  27290. */
  27291. readonly isStencilEnable: boolean;
  27292. /** @hidden */ private _prepareWorkingCanvas(): void;
  27293. /**
  27294. * Reset the texture cache to empty state
  27295. */
  27296. resetTextureCache(): void;
  27297. /**
  27298. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  27299. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27300. * @returns true if engine is in deterministic lock step mode
  27301. */
  27302. isDeterministicLockStep(): boolean;
  27303. /**
  27304. * Gets the max steps when engine is running in deterministic lock step
  27305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27306. * @returns the max steps
  27307. */
  27308. getLockstepMaxSteps(): number;
  27309. /**
  27310. * Gets an object containing information about the current webGL context
  27311. * @returns an object containing the vender, the renderer and the version of the current webGL context
  27312. */
  27313. getGlInfo(): {
  27314. vendor: string;
  27315. renderer: string;
  27316. version: string;
  27317. };
  27318. /**
  27319. * Gets current aspect ratio
  27320. * @param camera defines the camera to use to get the aspect ratio
  27321. * @param useScreen defines if screen size must be used (or the current render target if any)
  27322. * @returns a number defining the aspect ratio
  27323. */
  27324. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  27325. /**
  27326. * Gets current screen aspect ratio
  27327. * @returns a number defining the aspect ratio
  27328. */
  27329. getScreenAspectRatio(): number;
  27330. /**
  27331. * Gets the current render width
  27332. * @param useScreen defines if screen size must be used (or the current render target if any)
  27333. * @returns a number defining the current render width
  27334. */
  27335. getRenderWidth(useScreen?: boolean): number;
  27336. /**
  27337. * Gets the current render height
  27338. * @param useScreen defines if screen size must be used (or the current render target if any)
  27339. * @returns a number defining the current render height
  27340. */
  27341. getRenderHeight(useScreen?: boolean): number;
  27342. /**
  27343. * Gets the HTML canvas attached with the current webGL context
  27344. * @returns a HTML canvas
  27345. */
  27346. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  27347. /**
  27348. * Gets the client rect of the HTML canvas attached with the current webGL context
  27349. * @returns a client rectanglee
  27350. */
  27351. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  27352. /**
  27353. * Defines the hardware scaling level.
  27354. * By default the hardware scaling level is computed from the window device ratio.
  27355. * 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.
  27356. * @param level defines the level to use
  27357. */
  27358. setHardwareScalingLevel(level: number): void;
  27359. /**
  27360. * Gets the current hardware scaling level.
  27361. * By default the hardware scaling level is computed from the window device ratio.
  27362. * 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.
  27363. * @returns a number indicating the current hardware scaling level
  27364. */
  27365. getHardwareScalingLevel(): number;
  27366. /**
  27367. * Gets the list of loaded textures
  27368. * @returns an array containing all loaded textures
  27369. */
  27370. getLoadedTexturesCache(): InternalTexture[];
  27371. /**
  27372. * Gets the object containing all engine capabilities
  27373. * @returns the EngineCapabilities object
  27374. */
  27375. getCaps(): EngineCapabilities;
  27376. /**
  27377. * Gets the current depth function
  27378. * @returns a number defining the depth function
  27379. */
  27380. getDepthFunction(): Nullable<number>;
  27381. /**
  27382. * Sets the current depth function
  27383. * @param depthFunc defines the function to use
  27384. */
  27385. setDepthFunction(depthFunc: number): void;
  27386. /**
  27387. * Sets the current depth function to GREATER
  27388. */
  27389. setDepthFunctionToGreater(): void;
  27390. /**
  27391. * Sets the current depth function to GEQUAL
  27392. */
  27393. setDepthFunctionToGreaterOrEqual(): void;
  27394. /**
  27395. * Sets the current depth function to LESS
  27396. */
  27397. setDepthFunctionToLess(): void;
  27398. private _cachedStencilBuffer;
  27399. private _cachedStencilFunction;
  27400. private _cachedStencilMask;
  27401. private _cachedStencilOperationPass;
  27402. private _cachedStencilOperationFail;
  27403. private _cachedStencilOperationDepthFail;
  27404. private _cachedStencilReference;
  27405. /**
  27406. * Caches the the state of the stencil buffer
  27407. */
  27408. cacheStencilState(): void;
  27409. /**
  27410. * Restores the state of the stencil buffer
  27411. */
  27412. restoreStencilState(): void;
  27413. /**
  27414. * Sets the current depth function to LEQUAL
  27415. */
  27416. setDepthFunctionToLessOrEqual(): void;
  27417. /**
  27418. * Gets a boolean indicating if stencil buffer is enabled
  27419. * @returns the current stencil buffer state
  27420. */
  27421. getStencilBuffer(): boolean;
  27422. /**
  27423. * Enable or disable the stencil buffer
  27424. * @param enable defines if the stencil buffer must be enabled or disabled
  27425. */
  27426. setStencilBuffer(enable: boolean): void;
  27427. /**
  27428. * Gets the current stencil mask
  27429. * @returns a number defining the new stencil mask to use
  27430. */
  27431. getStencilMask(): number;
  27432. /**
  27433. * Sets the current stencil mask
  27434. * @param mask defines the new stencil mask to use
  27435. */
  27436. setStencilMask(mask: number): void;
  27437. /**
  27438. * Gets the current stencil function
  27439. * @returns a number defining the stencil function to use
  27440. */
  27441. getStencilFunction(): number;
  27442. /**
  27443. * Gets the current stencil reference value
  27444. * @returns a number defining the stencil reference value to use
  27445. */
  27446. getStencilFunctionReference(): number;
  27447. /**
  27448. * Gets the current stencil mask
  27449. * @returns a number defining the stencil mask to use
  27450. */
  27451. getStencilFunctionMask(): number;
  27452. /**
  27453. * Sets the current stencil function
  27454. * @param stencilFunc defines the new stencil function to use
  27455. */
  27456. setStencilFunction(stencilFunc: number): void;
  27457. /**
  27458. * Sets the current stencil reference
  27459. * @param reference defines the new stencil reference to use
  27460. */
  27461. setStencilFunctionReference(reference: number): void;
  27462. /**
  27463. * Sets the current stencil mask
  27464. * @param mask defines the new stencil mask to use
  27465. */
  27466. setStencilFunctionMask(mask: number): void;
  27467. /**
  27468. * Gets the current stencil operation when stencil fails
  27469. * @returns a number defining stencil operation to use when stencil fails
  27470. */
  27471. getStencilOperationFail(): number;
  27472. /**
  27473. * Gets the current stencil operation when depth fails
  27474. * @returns a number defining stencil operation to use when depth fails
  27475. */
  27476. getStencilOperationDepthFail(): number;
  27477. /**
  27478. * Gets the current stencil operation when stencil passes
  27479. * @returns a number defining stencil operation to use when stencil passes
  27480. */
  27481. getStencilOperationPass(): number;
  27482. /**
  27483. * Sets the stencil operation to use when stencil fails
  27484. * @param operation defines the stencil operation to use when stencil fails
  27485. */
  27486. setStencilOperationFail(operation: number): void;
  27487. /**
  27488. * Sets the stencil operation to use when depth fails
  27489. * @param operation defines the stencil operation to use when depth fails
  27490. */
  27491. setStencilOperationDepthFail(operation: number): void;
  27492. /**
  27493. * Sets the stencil operation to use when stencil passes
  27494. * @param operation defines the stencil operation to use when stencil passes
  27495. */
  27496. setStencilOperationPass(operation: number): void;
  27497. /**
  27498. * Sets a boolean indicating if the dithering state is enabled or disabled
  27499. * @param value defines the dithering state
  27500. */
  27501. setDitheringState(value: boolean): void;
  27502. /**
  27503. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  27504. * @param value defines the rasterizer state
  27505. */
  27506. setRasterizerState(value: boolean): void;
  27507. /**
  27508. * stop executing a render loop function and remove it from the execution array
  27509. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  27510. */
  27511. stopRenderLoop(renderFunction?: () => void): void;
  27512. /** @hidden */ private _renderLoop(): void;
  27513. /**
  27514. * Register and execute a render loop. The engine can have more than one render function
  27515. * @param renderFunction defines the function to continuously execute
  27516. */
  27517. runRenderLoop(renderFunction: () => void): void;
  27518. /**
  27519. * Toggle full screen mode
  27520. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27521. */
  27522. switchFullscreen(requestPointerLock: boolean): void;
  27523. /**
  27524. * Enters full screen mode
  27525. * @param requestPointerLock defines if a pointer lock should be requested from the user
  27526. */
  27527. enterFullscreen(requestPointerLock: boolean): void;
  27528. /**
  27529. * Exits full screen mode
  27530. */
  27531. exitFullscreen(): void;
  27532. /**
  27533. * Clear the current render buffer or the current render target (if any is set up)
  27534. * @param color defines the color to use
  27535. * @param backBuffer defines if the back buffer must be cleared
  27536. * @param depth defines if the depth buffer must be cleared
  27537. * @param stencil defines if the stencil buffer must be cleared
  27538. */
  27539. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  27540. /**
  27541. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  27542. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27543. * @param y defines the y-coordinate of the corner of the clear rectangle
  27544. * @param width defines the width of the clear rectangle
  27545. * @param height defines the height of the clear rectangle
  27546. * @param clearColor defines the clear color
  27547. */
  27548. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  27549. /**
  27550. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  27551. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  27552. * @param y defines the y-coordinate of the corner of the clear rectangle
  27553. * @param width defines the width of the clear rectangle
  27554. * @param height defines the height of the clear rectangle
  27555. */
  27556. enableScissor(x: number, y: number, width: number, height: number): void;
  27557. /**
  27558. * Disable previously set scissor test rectangle
  27559. */
  27560. disableScissor(): void;
  27561. private _viewportCached;
  27562. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  27563. /**
  27564. * Set the WebGL's viewport
  27565. * @param viewport defines the viewport element to be used
  27566. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  27567. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  27568. */
  27569. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  27570. /**
  27571. * Directly set the WebGL Viewport
  27572. * @param x defines the x coordinate of the viewport (in screen space)
  27573. * @param y defines the y coordinate of the viewport (in screen space)
  27574. * @param width defines the width of the viewport (in screen space)
  27575. * @param height defines the height of the viewport (in screen space)
  27576. * @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
  27577. */
  27578. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  27579. /**
  27580. * Begin a new frame
  27581. */
  27582. beginFrame(): void;
  27583. /**
  27584. * Enf the current frame
  27585. */
  27586. endFrame(): void;
  27587. /**
  27588. * Resize the view according to the canvas' size
  27589. */
  27590. resize(): void;
  27591. /**
  27592. * Force a specific size of the canvas
  27593. * @param width defines the new canvas' width
  27594. * @param height defines the new canvas' height
  27595. */
  27596. setSize(width: number, height: number): void;
  27597. /**
  27598. * Binds the frame buffer to the specified texture.
  27599. * @param texture The texture to render to or null for the default canvas
  27600. * @param faceIndex The face of the texture to render to in case of cube texture
  27601. * @param requiredWidth The width of the target to render to
  27602. * @param requiredHeight The height of the target to render to
  27603. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  27604. * @param depthStencilTexture The depth stencil texture to use to render
  27605. * @param lodLevel defines le lod level to bind to the frame buffer
  27606. */
  27607. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  27608. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  27609. /**
  27610. * Unbind the current render target texture from the webGL context
  27611. * @param texture defines the render target texture to unbind
  27612. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  27613. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  27614. */
  27615. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  27616. /**
  27617. * Force the mipmap generation for the given render target texture
  27618. * @param texture defines the render target texture to use
  27619. */
  27620. generateMipMapsForCubemap(texture: InternalTexture): void;
  27621. /**
  27622. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  27623. */
  27624. flushFramebuffer(): void;
  27625. /**
  27626. * Unbind the current render target and bind the default framebuffer
  27627. */
  27628. restoreDefaultFramebuffer(): void;
  27629. /**
  27630. * Create an uniform buffer
  27631. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27632. * @param elements defines the content of the uniform buffer
  27633. * @returns the webGL uniform buffer
  27634. */
  27635. createUniformBuffer(elements: FloatArray): DataBuffer;
  27636. /**
  27637. * Create a dynamic uniform buffer
  27638. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27639. * @param elements defines the content of the uniform buffer
  27640. * @returns the webGL uniform buffer
  27641. */
  27642. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  27643. /**
  27644. * Update an existing uniform buffer
  27645. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  27646. * @param uniformBuffer defines the target uniform buffer
  27647. * @param elements defines the content to update
  27648. * @param offset defines the offset in the uniform buffer where update should start
  27649. * @param count defines the size of the data to update
  27650. */
  27651. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  27652. private _resetVertexBufferBinding;
  27653. /**
  27654. * Creates a vertex buffer
  27655. * @param data the data for the vertex buffer
  27656. * @returns the new WebGL static buffer
  27657. */
  27658. createVertexBuffer(data: DataArray): DataBuffer;
  27659. /**
  27660. * Creates a dynamic vertex buffer
  27661. * @param data the data for the dynamic vertex buffer
  27662. * @returns the new WebGL dynamic buffer
  27663. */
  27664. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  27665. /**
  27666. * Update a dynamic index buffer
  27667. * @param indexBuffer defines the target index buffer
  27668. * @param indices defines the data to update
  27669. * @param offset defines the offset in the target index buffer where update should start
  27670. */
  27671. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  27672. /**
  27673. * Updates a dynamic vertex buffer.
  27674. * @param vertexBuffer the vertex buffer to update
  27675. * @param data the data used to update the vertex buffer
  27676. * @param byteOffset the byte offset of the data
  27677. * @param byteLength the byte length of the data
  27678. */
  27679. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  27680. private _resetIndexBufferBinding;
  27681. /**
  27682. * Creates a new index buffer
  27683. * @param indices defines the content of the index buffer
  27684. * @param updatable defines if the index buffer must be updatable
  27685. * @returns a new webGL buffer
  27686. */
  27687. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  27688. /**
  27689. * Bind a webGL buffer to the webGL context
  27690. * @param buffer defines the buffer to bind
  27691. */
  27692. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  27693. /**
  27694. * Bind an uniform buffer to the current webGL context
  27695. * @param buffer defines the buffer to bind
  27696. */
  27697. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  27698. /**
  27699. * Bind a buffer to the current webGL context at a given location
  27700. * @param buffer defines the buffer to bind
  27701. * @param location defines the index where to bind the buffer
  27702. */
  27703. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  27704. /**
  27705. * Bind a specific block at a given index in a specific shader program
  27706. * @param pipelineContext defines the pipeline context to use
  27707. * @param blockName defines the block name
  27708. * @param index defines the index where to bind the block
  27709. */
  27710. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  27711. private bindIndexBuffer;
  27712. private bindBuffer;
  27713. /**
  27714. * update the bound buffer with the given data
  27715. * @param data defines the data to update
  27716. */
  27717. updateArrayBuffer(data: Float32Array): void;
  27718. private _vertexAttribPointer;
  27719. private _bindIndexBufferWithCache;
  27720. private _bindVertexBuffersAttributes;
  27721. /**
  27722. * Records a vertex array object
  27723. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27724. * @param vertexBuffers defines the list of vertex buffers to store
  27725. * @param indexBuffer defines the index buffer to store
  27726. * @param effect defines the effect to store
  27727. * @returns the new vertex array object
  27728. */
  27729. recordVertexArrayObject(vertexBuffers: {
  27730. [key: string]: VertexBuffer;
  27731. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  27732. /**
  27733. * Bind a specific vertex array object
  27734. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  27735. * @param vertexArrayObject defines the vertex array object to bind
  27736. * @param indexBuffer defines the index buffer to bind
  27737. */
  27738. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  27739. /**
  27740. * Bind webGl buffers directly to the webGL context
  27741. * @param vertexBuffer defines the vertex buffer to bind
  27742. * @param indexBuffer defines the index buffer to bind
  27743. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  27744. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  27745. * @param effect defines the effect associated with the vertex buffer
  27746. */
  27747. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  27748. private _unbindVertexArrayObject;
  27749. /**
  27750. * Bind a list of vertex buffers to the webGL context
  27751. * @param vertexBuffers defines the list of vertex buffers to bind
  27752. * @param indexBuffer defines the index buffer to bind
  27753. * @param effect defines the effect associated with the vertex buffers
  27754. */
  27755. bindBuffers(vertexBuffers: {
  27756. [key: string]: Nullable<VertexBuffer>;
  27757. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  27758. /**
  27759. * Unbind all instance attributes
  27760. */
  27761. unbindInstanceAttributes(): void;
  27762. /**
  27763. * Release and free the memory of a vertex array object
  27764. * @param vao defines the vertex array object to delete
  27765. */
  27766. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  27767. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  27768. /**
  27769. * Creates a webGL buffer to use with instanciation
  27770. * @param capacity defines the size of the buffer
  27771. * @returns the webGL buffer
  27772. */
  27773. createInstancesBuffer(capacity: number): DataBuffer;
  27774. /**
  27775. * Delete a webGL buffer used with instanciation
  27776. * @param buffer defines the webGL buffer to delete
  27777. */
  27778. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  27779. /**
  27780. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  27781. * @param instancesBuffer defines the webGL buffer to update and bind
  27782. * @param data defines the data to store in the buffer
  27783. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  27784. */
  27785. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  27786. /**
  27787. * Apply all cached states (depth, culling, stencil and alpha)
  27788. */
  27789. applyStates(): void;
  27790. /**
  27791. * Send a draw order
  27792. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27793. * @param indexStart defines the starting index
  27794. * @param indexCount defines the number of index to draw
  27795. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27796. */
  27797. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  27798. /**
  27799. * Draw a list of points
  27800. * @param verticesStart defines the index of first vertex to draw
  27801. * @param verticesCount defines the count of vertices to draw
  27802. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27803. */
  27804. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27805. /**
  27806. * Draw a list of unindexed primitives
  27807. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  27808. * @param verticesStart defines the index of first vertex to draw
  27809. * @param verticesCount defines the count of vertices to draw
  27810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27811. */
  27812. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27813. /**
  27814. * Draw a list of indexed primitives
  27815. * @param fillMode defines the primitive to use
  27816. * @param indexStart defines the starting index
  27817. * @param indexCount defines the number of index to draw
  27818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27819. */
  27820. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  27821. /**
  27822. * Draw a list of unindexed primitives
  27823. * @param fillMode defines the primitive to use
  27824. * @param verticesStart defines the index of first vertex to draw
  27825. * @param verticesCount defines the count of vertices to draw
  27826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  27827. */
  27828. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  27829. private _drawMode;
  27830. /** @hidden */ private _releaseEffect(effect: Effect): void;
  27831. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  27832. /**
  27833. * Create a new effect (used to store vertex/fragment shaders)
  27834. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  27835. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  27836. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  27837. * @param samplers defines an array of string used to represent textures
  27838. * @param defines defines the string containing the defines to use to compile the shaders
  27839. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  27840. * @param onCompiled defines a function to call when the effect creation is successful
  27841. * @param onError defines a function to call when the effect creation has failed
  27842. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  27843. * @returns the new Effect
  27844. */
  27845. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  27846. private _compileShader;
  27847. private _compileRawShader;
  27848. /**
  27849. * Directly creates a webGL program
  27850. * @param pipelineContext defines the pipeline context to attach to
  27851. * @param vertexCode defines the vertex shader code to use
  27852. * @param fragmentCode defines the fragment shader code to use
  27853. * @param context defines the webGL context to use (if not set, the current one will be used)
  27854. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27855. * @returns the new webGL program
  27856. */
  27857. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27858. /**
  27859. * Creates a webGL program
  27860. * @param pipelineContext defines the pipeline context to attach to
  27861. * @param vertexCode defines the vertex shader code to use
  27862. * @param fragmentCode defines the fragment shader code to use
  27863. * @param defines defines the string containing the defines to use to compile the shaders
  27864. * @param context defines the webGL context to use (if not set, the current one will be used)
  27865. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  27866. * @returns the new webGL program
  27867. */
  27868. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  27869. /**
  27870. * Creates a new pipeline context
  27871. * @returns the new pipeline
  27872. */
  27873. createPipelineContext(): WebGLPipelineContext;
  27874. private _createShaderProgram;
  27875. private _finalizePipelineContext;
  27876. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  27877. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  27878. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  27879. /**
  27880. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  27881. * @param pipelineContext defines the pipeline context to use
  27882. * @param uniformsNames defines the list of uniform names
  27883. * @returns an array of webGL uniform locations
  27884. */
  27885. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  27886. /**
  27887. * Gets the lsit of active attributes for a given webGL program
  27888. * @param pipelineContext defines the pipeline context to use
  27889. * @param attributesNames defines the list of attribute names to get
  27890. * @returns an array of indices indicating the offset of each attribute
  27891. */
  27892. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  27893. /**
  27894. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  27895. * @param effect defines the effect to activate
  27896. */
  27897. enableEffect(effect: Nullable<Effect>): void;
  27898. /**
  27899. * Set the value of an uniform to an array of int32
  27900. * @param uniform defines the webGL uniform location where to store the value
  27901. * @param array defines the array of int32 to store
  27902. */
  27903. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27904. /**
  27905. * Set the value of an uniform to an array of int32 (stored as vec2)
  27906. * @param uniform defines the webGL uniform location where to store the value
  27907. * @param array defines the array of int32 to store
  27908. */
  27909. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27910. /**
  27911. * Set the value of an uniform to an array of int32 (stored as vec3)
  27912. * @param uniform defines the webGL uniform location where to store the value
  27913. * @param array defines the array of int32 to store
  27914. */
  27915. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27916. /**
  27917. * Set the value of an uniform to an array of int32 (stored as vec4)
  27918. * @param uniform defines the webGL uniform location where to store the value
  27919. * @param array defines the array of int32 to store
  27920. */
  27921. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  27922. /**
  27923. * Set the value of an uniform to an array of float32
  27924. * @param uniform defines the webGL uniform location where to store the value
  27925. * @param array defines the array of float32 to store
  27926. */
  27927. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27928. /**
  27929. * Set the value of an uniform to an array of float32 (stored as vec2)
  27930. * @param uniform defines the webGL uniform location where to store the value
  27931. * @param array defines the array of float32 to store
  27932. */
  27933. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27934. /**
  27935. * Set the value of an uniform to an array of float32 (stored as vec3)
  27936. * @param uniform defines the webGL uniform location where to store the value
  27937. * @param array defines the array of float32 to store
  27938. */
  27939. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27940. /**
  27941. * Set the value of an uniform to an array of float32 (stored as vec4)
  27942. * @param uniform defines the webGL uniform location where to store the value
  27943. * @param array defines the array of float32 to store
  27944. */
  27945. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  27946. /**
  27947. * Set the value of an uniform to an array of number
  27948. * @param uniform defines the webGL uniform location where to store the value
  27949. * @param array defines the array of number to store
  27950. */
  27951. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27952. /**
  27953. * Set the value of an uniform to an array of number (stored as vec2)
  27954. * @param uniform defines the webGL uniform location where to store the value
  27955. * @param array defines the array of number to store
  27956. */
  27957. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27958. /**
  27959. * Set the value of an uniform to an array of number (stored as vec3)
  27960. * @param uniform defines the webGL uniform location where to store the value
  27961. * @param array defines the array of number to store
  27962. */
  27963. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27964. /**
  27965. * Set the value of an uniform to an array of number (stored as vec4)
  27966. * @param uniform defines the webGL uniform location where to store the value
  27967. * @param array defines the array of number to store
  27968. */
  27969. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  27970. /**
  27971. * Set the value of an uniform to an array of float32 (stored as matrices)
  27972. * @param uniform defines the webGL uniform location where to store the value
  27973. * @param matrices defines the array of float32 to store
  27974. */
  27975. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  27976. /**
  27977. * Set the value of an uniform to a matrix
  27978. * @param uniform defines the webGL uniform location where to store the value
  27979. * @param matrix defines the matrix to store
  27980. */
  27981. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  27982. /**
  27983. * Set the value of an uniform to a matrix (3x3)
  27984. * @param uniform defines the webGL uniform location where to store the value
  27985. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  27986. */
  27987. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27988. /**
  27989. * Set the value of an uniform to a matrix (2x2)
  27990. * @param uniform defines the webGL uniform location where to store the value
  27991. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  27992. */
  27993. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  27994. /**
  27995. * Set the value of an uniform to a number (int)
  27996. * @param uniform defines the webGL uniform location where to store the value
  27997. * @param value defines the int number to store
  27998. */
  27999. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28000. /**
  28001. * Set the value of an uniform to a number (float)
  28002. * @param uniform defines the webGL uniform location where to store the value
  28003. * @param value defines the float number to store
  28004. */
  28005. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  28006. /**
  28007. * Set the value of an uniform to a vec2
  28008. * @param uniform defines the webGL uniform location where to store the value
  28009. * @param x defines the 1st component of the value
  28010. * @param y defines the 2nd component of the value
  28011. */
  28012. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  28013. /**
  28014. * Set the value of an uniform to a vec3
  28015. * @param uniform defines the webGL uniform location where to store the value
  28016. * @param x defines the 1st component of the value
  28017. * @param y defines the 2nd component of the value
  28018. * @param z defines the 3rd component of the value
  28019. */
  28020. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  28021. /**
  28022. * Set the value of an uniform to a boolean
  28023. * @param uniform defines the webGL uniform location where to store the value
  28024. * @param bool defines the boolean to store
  28025. */
  28026. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  28027. /**
  28028. * Set the value of an uniform to a vec4
  28029. * @param uniform defines the webGL uniform location where to store the value
  28030. * @param x defines the 1st component of the value
  28031. * @param y defines the 2nd component of the value
  28032. * @param z defines the 3rd component of the value
  28033. * @param w defines the 4th component of the value
  28034. */
  28035. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  28036. /**
  28037. * Set the value of an uniform to a Color3
  28038. * @param uniform defines the webGL uniform location where to store the value
  28039. * @param color3 defines the color to store
  28040. */
  28041. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  28042. /**
  28043. * Set the value of an uniform to a Color3 and an alpha value
  28044. * @param uniform defines the webGL uniform location where to store the value
  28045. * @param color3 defines the color to store
  28046. * @param alpha defines the alpha component to store
  28047. */
  28048. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  28049. /**
  28050. * Sets a Color4 on a uniform variable
  28051. * @param uniform defines the uniform location
  28052. * @param color4 defines the value to be set
  28053. */
  28054. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  28055. /**
  28056. * Set various states to the webGL context
  28057. * @param culling defines backface culling state
  28058. * @param zOffset defines the value to apply to zOffset (0 by default)
  28059. * @param force defines if states must be applied even if cache is up to date
  28060. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  28061. */
  28062. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  28063. /**
  28064. * Set the z offset to apply to current rendering
  28065. * @param value defines the offset to apply
  28066. */
  28067. setZOffset(value: number): void;
  28068. /**
  28069. * Gets the current value of the zOffset
  28070. * @returns the current zOffset state
  28071. */
  28072. getZOffset(): number;
  28073. /**
  28074. * Enable or disable depth buffering
  28075. * @param enable defines the state to set
  28076. */
  28077. setDepthBuffer(enable: boolean): void;
  28078. /**
  28079. * Gets a boolean indicating if depth writing is enabled
  28080. * @returns the current depth writing state
  28081. */
  28082. getDepthWrite(): boolean;
  28083. /**
  28084. * Enable or disable depth writing
  28085. * @param enable defines the state to set
  28086. */
  28087. setDepthWrite(enable: boolean): void;
  28088. /**
  28089. * Enable or disable color writing
  28090. * @param enable defines the state to set
  28091. */
  28092. setColorWrite(enable: boolean): void;
  28093. /**
  28094. * Gets a boolean indicating if color writing is enabled
  28095. * @returns the current color writing state
  28096. */
  28097. getColorWrite(): boolean;
  28098. /**
  28099. * Sets alpha constants used by some alpha blending modes
  28100. * @param r defines the red component
  28101. * @param g defines the green component
  28102. * @param b defines the blue component
  28103. * @param a defines the alpha component
  28104. */
  28105. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  28106. /**
  28107. * Sets the current alpha mode
  28108. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  28109. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  28110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28111. */
  28112. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  28113. /**
  28114. * Gets the current alpha mode
  28115. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  28116. * @returns the current alpha mode
  28117. */
  28118. getAlphaMode(): number;
  28119. /**
  28120. * Clears the list of texture accessible through engine.
  28121. * This can help preventing texture load conflict due to name collision.
  28122. */
  28123. clearInternalTexturesCache(): void;
  28124. /**
  28125. * Force the entire cache to be cleared
  28126. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  28127. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  28128. */
  28129. wipeCaches(bruteForce?: boolean): void;
  28130. /**
  28131. * Set the compressed texture format to use, based on the formats you have, and the formats
  28132. * supported by the hardware / browser.
  28133. *
  28134. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  28135. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  28136. * to API arguments needed to compressed textures. This puts the burden on the container
  28137. * generator to house the arcane code for determining these for current & future formats.
  28138. *
  28139. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  28140. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  28141. *
  28142. * Note: The result of this call is not taken into account when a texture is base64.
  28143. *
  28144. * @param formatsAvailable defines the list of those format families you have created
  28145. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  28146. *
  28147. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  28148. * @returns The extension selected.
  28149. */
  28150. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  28151. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  28152. min: number;
  28153. mag: number;
  28154. };
  28155. /** @hidden */ private _createTexture(): WebGLTexture;
  28156. /**
  28157. * Usually called from Texture.ts.
  28158. * Passed information to create a WebGLTexture
  28159. * @param urlArg defines a value which contains one of the following:
  28160. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  28161. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  28162. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  28163. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  28164. * @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)
  28165. * @param scene needed for loading to the correct scene
  28166. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  28167. * @param onLoad optional callback to be called upon successful completion
  28168. * @param onError optional callback to be called upon failure
  28169. * @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
  28170. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  28171. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  28172. * @param forcedExtension defines the extension to use to pick the right loader
  28173. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  28174. * @returns a InternalTexture for assignment back into BABYLON.Texture
  28175. */
  28176. 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;
  28177. private _rescaleTexture;
  28178. private _unpackFlipYCached;
  28179. /**
  28180. * In case you are sharing the context with other applications, it might
  28181. * be interested to not cache the unpack flip y state to ensure a consistent
  28182. * value would be set.
  28183. */
  28184. enableUnpackFlipYCached: boolean;
  28185. /** @hidden */ private _unpackFlipY(value: boolean): void;
  28186. /** @hidden */ private _getUnpackAlignement(): number;
  28187. /**
  28188. * Creates a dynamic texture
  28189. * @param width defines the width of the texture
  28190. * @param height defines the height of the texture
  28191. * @param generateMipMaps defines if the engine should generate the mip levels
  28192. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  28193. * @returns the dynamic texture inside an InternalTexture
  28194. */
  28195. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  28196. /**
  28197. * Update the sampling mode of a given texture
  28198. * @param samplingMode defines the required sampling mode
  28199. * @param texture defines the texture to update
  28200. */
  28201. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  28202. /**
  28203. * Update the content of a dynamic texture
  28204. * @param texture defines the texture to update
  28205. * @param canvas defines the canvas containing the source
  28206. * @param invertY defines if data must be stored with Y axis inverted
  28207. * @param premulAlpha defines if alpha is stored as premultiplied
  28208. * @param format defines the format of the data
  28209. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  28210. */
  28211. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  28212. /**
  28213. * Update a video texture
  28214. * @param texture defines the texture to update
  28215. * @param video defines the video element to use
  28216. * @param invertY defines if data must be stored with Y axis inverted
  28217. */
  28218. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  28219. /**
  28220. * Updates a depth texture Comparison Mode and Function.
  28221. * If the comparison Function is equal to 0, the mode will be set to none.
  28222. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  28223. * @param texture The texture to set the comparison function for
  28224. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  28225. */
  28226. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  28227. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  28228. width: number;
  28229. height: number;
  28230. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  28231. /**
  28232. * Creates a depth stencil texture.
  28233. * This is only available in WebGL 2 or with the depth texture extension available.
  28234. * @param size The size of face edge in the texture.
  28235. * @param options The options defining the texture.
  28236. * @returns The texture
  28237. */
  28238. createDepthStencilTexture(size: number | {
  28239. width: number;
  28240. height: number;
  28241. }, options: DepthTextureCreationOptions): InternalTexture;
  28242. /**
  28243. * Creates a depth stencil texture.
  28244. * This is only available in WebGL 2 or with the depth texture extension available.
  28245. * @param size The size of face edge in the texture.
  28246. * @param options The options defining the texture.
  28247. * @returns The texture
  28248. */
  28249. private _createDepthStencilTexture;
  28250. /**
  28251. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  28252. * @param renderTarget The render target to set the frame buffer for
  28253. */
  28254. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  28255. /**
  28256. * Creates a new render target texture
  28257. * @param size defines the size of the texture
  28258. * @param options defines the options used to create the texture
  28259. * @returns a new render target texture stored in an InternalTexture
  28260. */
  28261. createRenderTargetTexture(size: number | {
  28262. width: number;
  28263. height: number;
  28264. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  28265. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  28266. /**
  28267. * Updates the sample count of a render target texture
  28268. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  28269. * @param texture defines the texture to update
  28270. * @param samples defines the sample count to set
  28271. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  28272. */
  28273. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  28274. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28275. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28276. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  28277. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  28278. /**
  28279. * @hidden
  28280. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  28281. private _prepareWebGLTextureContinuation;
  28282. private _prepareWebGLTexture;
  28283. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  28284. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  28285. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  28286. private setProgram;
  28287. private _boundUniforms;
  28288. /**
  28289. * Binds an effect to the webGL context
  28290. * @param effect defines the effect to bind
  28291. */
  28292. bindSamplers(effect: Effect): void;
  28293. private _activateCurrentTexture;
  28294. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  28295. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  28296. /**
  28297. * Sets a texture to the webGL context from a postprocess
  28298. * @param channel defines the channel to use
  28299. * @param postProcess defines the source postprocess
  28300. */
  28301. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  28302. /**
  28303. * Binds the output of the passed in post process to the texture channel specified
  28304. * @param channel The channel the texture should be bound to
  28305. * @param postProcess The post process which's output should be bound
  28306. */
  28307. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  28308. /**
  28309. * Unbind all textures from the webGL context
  28310. */
  28311. unbindAllTextures(): void;
  28312. /**
  28313. * Sets a texture to the according uniform.
  28314. * @param channel The texture channel
  28315. * @param uniform The uniform to set
  28316. * @param texture The texture to apply
  28317. */
  28318. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  28319. /**
  28320. * Sets a depth stencil texture from a render target to the according uniform.
  28321. * @param channel The texture channel
  28322. * @param uniform The uniform to set
  28323. * @param texture The render target texture containing the depth stencil texture to apply
  28324. */
  28325. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  28326. private _bindSamplerUniformToChannel;
  28327. private _getTextureWrapMode;
  28328. private _setTexture;
  28329. /**
  28330. * Sets an array of texture to the webGL context
  28331. * @param channel defines the channel where the texture array must be set
  28332. * @param uniform defines the associated uniform location
  28333. * @param textures defines the array of textures to bind
  28334. */
  28335. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  28336. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  28337. private _setTextureParameterFloat;
  28338. private _setTextureParameterInteger;
  28339. /**
  28340. * Reads pixels from the current frame buffer. Please note that this function can be slow
  28341. * @param x defines the x coordinate of the rectangle where pixels must be read
  28342. * @param y defines the y coordinate of the rectangle where pixels must be read
  28343. * @param width defines the width of the rectangle where pixels must be read
  28344. * @param height defines the height of the rectangle where pixels must be read
  28345. * @returns a Uint8Array containing RGBA colors
  28346. */
  28347. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  28348. /**
  28349. * Add an externaly attached data from its key.
  28350. * This method call will fail and return false, if such key already exists.
  28351. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  28352. * @param key the unique key that identifies the data
  28353. * @param data the data object to associate to the key for this Engine instance
  28354. * @return true if no such key were already present and the data was added successfully, false otherwise
  28355. */
  28356. addExternalData<T>(key: string, data: T): boolean;
  28357. /**
  28358. * Get an externaly attached data from its key
  28359. * @param key the unique key that identifies the data
  28360. * @return the associated data, if present (can be null), or undefined if not present
  28361. */
  28362. getExternalData<T>(key: string): T;
  28363. /**
  28364. * Get an externaly attached data from its key, create it using a factory if it's not already present
  28365. * @param key the unique key that identifies the data
  28366. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  28367. * @return the associated data, can be null if the factory returned null.
  28368. */
  28369. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  28370. /**
  28371. * Remove an externaly attached data from the Engine instance
  28372. * @param key the unique key that identifies the data
  28373. * @return true if the data was successfully removed, false if it doesn't exist
  28374. */
  28375. removeExternalData(key: string): boolean;
  28376. /**
  28377. * Unbind all vertex attributes from the webGL context
  28378. */
  28379. unbindAllAttributes(): void;
  28380. /**
  28381. * 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
  28382. */
  28383. releaseEffects(): void;
  28384. /**
  28385. * Dispose and release all associated resources
  28386. */
  28387. dispose(): void;
  28388. /**
  28389. * Display the loading screen
  28390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28391. */
  28392. displayLoadingUI(): void;
  28393. /**
  28394. * Hide the loading screen
  28395. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28396. */
  28397. hideLoadingUI(): void;
  28398. /**
  28399. * Gets the current loading screen object
  28400. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28401. */
  28402. /**
  28403. * Sets the current loading screen object
  28404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28405. */
  28406. loadingScreen: ILoadingScreen;
  28407. /**
  28408. * Sets the current loading screen text
  28409. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28410. */
  28411. loadingUIText: string;
  28412. /**
  28413. * Sets the current loading screen background color
  28414. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28415. */
  28416. loadingUIBackgroundColor: string;
  28417. /**
  28418. * Attach a new callback raised when context lost event is fired
  28419. * @param callback defines the callback to call
  28420. */
  28421. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28422. /**
  28423. * Attach a new callback raised when context restored event is fired
  28424. * @param callback defines the callback to call
  28425. */
  28426. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  28427. /**
  28428. * Gets the source code of the vertex shader associated with a specific webGL program
  28429. * @param program defines the program to use
  28430. * @returns a string containing the source code of the vertex shader associated with the program
  28431. */
  28432. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  28433. /**
  28434. * Gets the source code of the fragment shader associated with a specific webGL program
  28435. * @param program defines the program to use
  28436. * @returns a string containing the source code of the fragment shader associated with the program
  28437. */
  28438. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  28439. /**
  28440. * Get the current error code of the webGL context
  28441. * @returns the error code
  28442. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  28443. */
  28444. getError(): number;
  28445. /**
  28446. * Gets the current framerate
  28447. * @returns a number representing the framerate
  28448. */
  28449. getFps(): number;
  28450. /**
  28451. * Gets the time spent between current and previous frame
  28452. * @returns a number representing the delta time in ms
  28453. */
  28454. getDeltaTime(): number;
  28455. private _measureFps;
  28456. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  28457. private _canRenderToFloatFramebuffer;
  28458. private _canRenderToHalfFloatFramebuffer;
  28459. private _canRenderToFramebuffer;
  28460. /** @hidden */ private _getWebGLTextureType(type: number): number;
  28461. /** @hidden */ private _getInternalFormat(format: number): number;
  28462. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  28463. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  28464. /** @hidden */ private _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;
  28465. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  28466. /**
  28467. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  28468. * @returns true if the engine can be created
  28469. * @ignorenaming
  28470. */
  28471. static isSupported(): boolean;
  28472. }
  28473. }
  28474. declare module BABYLON {
  28475. /**
  28476. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  28477. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  28478. */
  28479. export class EffectFallbacks {
  28480. private _defines;
  28481. private _currentRank;
  28482. private _maxRank;
  28483. private _mesh;
  28484. /**
  28485. * Removes the fallback from the bound mesh.
  28486. */
  28487. unBindMesh(): void;
  28488. /**
  28489. * Adds a fallback on the specified property.
  28490. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28491. * @param define The name of the define in the shader
  28492. */
  28493. addFallback(rank: number, define: string): void;
  28494. /**
  28495. * Sets the mesh to use CPU skinning when needing to fallback.
  28496. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  28497. * @param mesh The mesh to use the fallbacks.
  28498. */
  28499. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  28500. /**
  28501. * Checks to see if more fallbacks are still availible.
  28502. */
  28503. readonly isMoreFallbacks: boolean;
  28504. /**
  28505. * Removes the defines that shoould be removed when falling back.
  28506. * @param currentDefines defines the current define statements for the shader.
  28507. * @param effect defines the current effect we try to compile
  28508. * @returns The resulting defines with defines of the current rank removed.
  28509. */
  28510. reduce(currentDefines: string, effect: Effect): string;
  28511. }
  28512. /**
  28513. * Options to be used when creating an effect.
  28514. */
  28515. export class EffectCreationOptions {
  28516. /**
  28517. * Atrributes that will be used in the shader.
  28518. */
  28519. attributes: string[];
  28520. /**
  28521. * Uniform varible names that will be set in the shader.
  28522. */
  28523. uniformsNames: string[];
  28524. /**
  28525. * Uniform buffer varible names that will be set in the shader.
  28526. */
  28527. uniformBuffersNames: string[];
  28528. /**
  28529. * Sampler texture variable names that will be set in the shader.
  28530. */
  28531. samplers: string[];
  28532. /**
  28533. * Define statements that will be set in the shader.
  28534. */
  28535. defines: any;
  28536. /**
  28537. * Possible fallbacks for this effect to improve performance when needed.
  28538. */
  28539. fallbacks: Nullable<EffectFallbacks>;
  28540. /**
  28541. * Callback that will be called when the shader is compiled.
  28542. */
  28543. onCompiled: Nullable<(effect: Effect) => void>;
  28544. /**
  28545. * Callback that will be called if an error occurs during shader compilation.
  28546. */
  28547. onError: Nullable<(effect: Effect, errors: string) => void>;
  28548. /**
  28549. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28550. */
  28551. indexParameters: any;
  28552. /**
  28553. * Max number of lights that can be used in the shader.
  28554. */
  28555. maxSimultaneousLights: number;
  28556. /**
  28557. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28558. */
  28559. transformFeedbackVaryings: Nullable<string[]>;
  28560. }
  28561. /**
  28562. * Effect containing vertex and fragment shader that can be executed on an object.
  28563. */
  28564. export class Effect implements IDisposable {
  28565. /**
  28566. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28567. */
  28568. static ShadersRepository: string;
  28569. /**
  28570. * Name of the effect.
  28571. */
  28572. name: any;
  28573. /**
  28574. * String container all the define statements that should be set on the shader.
  28575. */
  28576. defines: string;
  28577. /**
  28578. * Callback that will be called when the shader is compiled.
  28579. */
  28580. onCompiled: Nullable<(effect: Effect) => void>;
  28581. /**
  28582. * Callback that will be called if an error occurs during shader compilation.
  28583. */
  28584. onError: Nullable<(effect: Effect, errors: string) => void>;
  28585. /**
  28586. * Callback that will be called when effect is bound.
  28587. */
  28588. onBind: Nullable<(effect: Effect) => void>;
  28589. /**
  28590. * Unique ID of the effect.
  28591. */
  28592. uniqueId: number;
  28593. /**
  28594. * Observable that will be called when the shader is compiled.
  28595. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28596. */
  28597. onCompileObservable: Observable<Effect>;
  28598. /**
  28599. * Observable that will be called if an error occurs during shader compilation.
  28600. */
  28601. onErrorObservable: Observable<Effect>;
  28602. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  28603. /**
  28604. * Observable that will be called when effect is bound.
  28605. */
  28606. readonly onBindObservable: Observable<Effect>;
  28607. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  28608. private static _uniqueIdSeed;
  28609. private _engine;
  28610. private _uniformBuffersNames;
  28611. private _uniformsNames;
  28612. private _samplerList;
  28613. private _samplers;
  28614. private _isReady;
  28615. private _compilationError;
  28616. private _attributesNames;
  28617. private _attributes;
  28618. private _uniforms;
  28619. /**
  28620. * Key for the effect.
  28621. * @hidden
  28622. */ private _key: string;
  28623. private _indexParameters;
  28624. private _fallbacks;
  28625. private _vertexSourceCode;
  28626. private _fragmentSourceCode;
  28627. private _vertexSourceCodeOverride;
  28628. private _fragmentSourceCodeOverride;
  28629. private _transformFeedbackVaryings;
  28630. /**
  28631. * Compiled shader to webGL program.
  28632. * @hidden
  28633. */ private _pipelineContext: Nullable<IPipelineContext>;
  28634. private _valueCache;
  28635. private static _baseCache;
  28636. /**
  28637. * Instantiates an effect.
  28638. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28639. * @param baseName Name of the effect.
  28640. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28641. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28642. * @param samplers List of sampler variables that will be passed to the shader.
  28643. * @param engine Engine to be used to render the effect
  28644. * @param defines Define statements to be added to the shader.
  28645. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28646. * @param onCompiled Callback that will be called when the shader is compiled.
  28647. * @param onError Callback that will be called if an error occurs during shader compilation.
  28648. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28649. */
  28650. 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);
  28651. /**
  28652. * Unique key for this effect
  28653. */
  28654. readonly key: string;
  28655. /**
  28656. * If the effect has been compiled and prepared.
  28657. * @returns if the effect is compiled and prepared.
  28658. */
  28659. isReady(): boolean;
  28660. /**
  28661. * The engine the effect was initialized with.
  28662. * @returns the engine.
  28663. */
  28664. getEngine(): Engine;
  28665. /**
  28666. * The pipeline context for this effect
  28667. * @returns the associated pipeline context
  28668. */
  28669. getPipelineContext(): Nullable<IPipelineContext>;
  28670. /**
  28671. * The set of names of attribute variables for the shader.
  28672. * @returns An array of attribute names.
  28673. */
  28674. getAttributesNames(): string[];
  28675. /**
  28676. * Returns the attribute at the given index.
  28677. * @param index The index of the attribute.
  28678. * @returns The location of the attribute.
  28679. */
  28680. getAttributeLocation(index: number): number;
  28681. /**
  28682. * Returns the attribute based on the name of the variable.
  28683. * @param name of the attribute to look up.
  28684. * @returns the attribute location.
  28685. */
  28686. getAttributeLocationByName(name: string): number;
  28687. /**
  28688. * The number of attributes.
  28689. * @returns the numnber of attributes.
  28690. */
  28691. getAttributesCount(): number;
  28692. /**
  28693. * Gets the index of a uniform variable.
  28694. * @param uniformName of the uniform to look up.
  28695. * @returns the index.
  28696. */
  28697. getUniformIndex(uniformName: string): number;
  28698. /**
  28699. * Returns the attribute based on the name of the variable.
  28700. * @param uniformName of the uniform to look up.
  28701. * @returns the location of the uniform.
  28702. */
  28703. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28704. /**
  28705. * Returns an array of sampler variable names
  28706. * @returns The array of sampler variable neames.
  28707. */
  28708. getSamplers(): string[];
  28709. /**
  28710. * The error from the last compilation.
  28711. * @returns the error string.
  28712. */
  28713. getCompilationError(): string;
  28714. /**
  28715. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  28716. * @param func The callback to be used.
  28717. */
  28718. executeWhenCompiled(func: (effect: Effect) => void): void;
  28719. private _checkIsReady;
  28720. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  28721. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  28722. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  28723. private _processShaderConversion;
  28724. private _processIncludes;
  28725. private _processPrecision;
  28726. /**
  28727. * Recompiles the webGL program
  28728. * @param vertexSourceCode The source code for the vertex shader.
  28729. * @param fragmentSourceCode The source code for the fragment shader.
  28730. * @param onCompiled Callback called when completed.
  28731. * @param onError Callback called on error.
  28732. * @hidden
  28733. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  28734. /**
  28735. * Prepares the effect
  28736. * @hidden
  28737. */ private _prepareEffect(): void;
  28738. /**
  28739. * Checks if the effect is supported. (Must be called after compilation)
  28740. */
  28741. readonly isSupported: boolean;
  28742. /**
  28743. * Binds a texture to the engine to be used as output of the shader.
  28744. * @param channel Name of the output variable.
  28745. * @param texture Texture to bind.
  28746. * @hidden
  28747. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  28748. /**
  28749. * Sets a texture on the engine to be used in the shader.
  28750. * @param channel Name of the sampler variable.
  28751. * @param texture Texture to set.
  28752. */
  28753. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  28754. /**
  28755. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  28756. * @param channel Name of the sampler variable.
  28757. * @param texture Texture to set.
  28758. */
  28759. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  28760. /**
  28761. * Sets an array of textures on the engine to be used in the shader.
  28762. * @param channel Name of the variable.
  28763. * @param textures Textures to set.
  28764. */
  28765. setTextureArray(channel: string, textures: BaseTexture[]): void;
  28766. /**
  28767. * 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)
  28768. * @param channel Name of the sampler variable.
  28769. * @param postProcess Post process to get the input texture from.
  28770. */
  28771. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  28772. /**
  28773. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  28774. * 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)
  28775. * @param channel Name of the sampler variable.
  28776. * @param postProcess Post process to get the output texture from.
  28777. */
  28778. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  28779. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  28780. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  28781. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  28782. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  28783. /**
  28784. * Binds a buffer to a uniform.
  28785. * @param buffer Buffer to bind.
  28786. * @param name Name of the uniform variable to bind to.
  28787. */
  28788. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  28789. /**
  28790. * Binds block to a uniform.
  28791. * @param blockName Name of the block to bind.
  28792. * @param index Index to bind.
  28793. */
  28794. bindUniformBlock(blockName: string, index: number): void;
  28795. /**
  28796. * Sets an interger value on a uniform variable.
  28797. * @param uniformName Name of the variable.
  28798. * @param value Value to be set.
  28799. * @returns this effect.
  28800. */
  28801. setInt(uniformName: string, value: number): Effect;
  28802. /**
  28803. * Sets an int array on a uniform variable.
  28804. * @param uniformName Name of the variable.
  28805. * @param array array to be set.
  28806. * @returns this effect.
  28807. */
  28808. setIntArray(uniformName: string, array: Int32Array): Effect;
  28809. /**
  28810. * 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)
  28811. * @param uniformName Name of the variable.
  28812. * @param array array to be set.
  28813. * @returns this effect.
  28814. */
  28815. setIntArray2(uniformName: string, array: Int32Array): Effect;
  28816. /**
  28817. * 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)
  28818. * @param uniformName Name of the variable.
  28819. * @param array array to be set.
  28820. * @returns this effect.
  28821. */
  28822. setIntArray3(uniformName: string, array: Int32Array): Effect;
  28823. /**
  28824. * 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)
  28825. * @param uniformName Name of the variable.
  28826. * @param array array to be set.
  28827. * @returns this effect.
  28828. */
  28829. setIntArray4(uniformName: string, array: Int32Array): Effect;
  28830. /**
  28831. * Sets an float array on a uniform variable.
  28832. * @param uniformName Name of the variable.
  28833. * @param array array to be set.
  28834. * @returns this effect.
  28835. */
  28836. setFloatArray(uniformName: string, array: Float32Array): Effect;
  28837. /**
  28838. * 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)
  28839. * @param uniformName Name of the variable.
  28840. * @param array array to be set.
  28841. * @returns this effect.
  28842. */
  28843. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  28844. /**
  28845. * 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)
  28846. * @param uniformName Name of the variable.
  28847. * @param array array to be set.
  28848. * @returns this effect.
  28849. */
  28850. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  28851. /**
  28852. * 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)
  28853. * @param uniformName Name of the variable.
  28854. * @param array array to be set.
  28855. * @returns this effect.
  28856. */
  28857. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  28858. /**
  28859. * Sets an array on a uniform variable.
  28860. * @param uniformName Name of the variable.
  28861. * @param array array to be set.
  28862. * @returns this effect.
  28863. */
  28864. setArray(uniformName: string, array: number[]): Effect;
  28865. /**
  28866. * 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)
  28867. * @param uniformName Name of the variable.
  28868. * @param array array to be set.
  28869. * @returns this effect.
  28870. */
  28871. setArray2(uniformName: string, array: number[]): Effect;
  28872. /**
  28873. * 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)
  28874. * @param uniformName Name of the variable.
  28875. * @param array array to be set.
  28876. * @returns this effect.
  28877. */
  28878. setArray3(uniformName: string, array: number[]): Effect;
  28879. /**
  28880. * 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)
  28881. * @param uniformName Name of the variable.
  28882. * @param array array to be set.
  28883. * @returns this effect.
  28884. */
  28885. setArray4(uniformName: string, array: number[]): Effect;
  28886. /**
  28887. * Sets matrices on a uniform variable.
  28888. * @param uniformName Name of the variable.
  28889. * @param matrices matrices to be set.
  28890. * @returns this effect.
  28891. */
  28892. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  28893. /**
  28894. * Sets matrix on a uniform variable.
  28895. * @param uniformName Name of the variable.
  28896. * @param matrix matrix to be set.
  28897. * @returns this effect.
  28898. */
  28899. setMatrix(uniformName: string, matrix: Matrix): Effect;
  28900. /**
  28901. * 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)
  28902. * @param uniformName Name of the variable.
  28903. * @param matrix matrix to be set.
  28904. * @returns this effect.
  28905. */
  28906. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28907. /**
  28908. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28909. * @param uniformName Name of the variable.
  28910. * @param matrix matrix to be set.
  28911. * @returns this effect.
  28912. */
  28913. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28914. /**
  28915. * Sets a float on a uniform variable.
  28916. * @param uniformName Name of the variable.
  28917. * @param value value to be set.
  28918. * @returns this effect.
  28919. */
  28920. setFloat(uniformName: string, value: number): Effect;
  28921. /**
  28922. * Sets a boolean on a uniform variable.
  28923. * @param uniformName Name of the variable.
  28924. * @param bool value to be set.
  28925. * @returns this effect.
  28926. */
  28927. setBool(uniformName: string, bool: boolean): Effect;
  28928. /**
  28929. * Sets a Vector2 on a uniform variable.
  28930. * @param uniformName Name of the variable.
  28931. * @param vector2 vector2 to be set.
  28932. * @returns this effect.
  28933. */
  28934. setVector2(uniformName: string, vector2: Vector2): Effect;
  28935. /**
  28936. * Sets a float2 on a uniform variable.
  28937. * @param uniformName Name of the variable.
  28938. * @param x First float in float2.
  28939. * @param y Second float in float2.
  28940. * @returns this effect.
  28941. */
  28942. setFloat2(uniformName: string, x: number, y: number): Effect;
  28943. /**
  28944. * Sets a Vector3 on a uniform variable.
  28945. * @param uniformName Name of the variable.
  28946. * @param vector3 Value to be set.
  28947. * @returns this effect.
  28948. */
  28949. setVector3(uniformName: string, vector3: Vector3): Effect;
  28950. /**
  28951. * Sets a float3 on a uniform variable.
  28952. * @param uniformName Name of the variable.
  28953. * @param x First float in float3.
  28954. * @param y Second float in float3.
  28955. * @param z Third float in float3.
  28956. * @returns this effect.
  28957. */
  28958. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28959. /**
  28960. * Sets a Vector4 on a uniform variable.
  28961. * @param uniformName Name of the variable.
  28962. * @param vector4 Value to be set.
  28963. * @returns this effect.
  28964. */
  28965. setVector4(uniformName: string, vector4: Vector4): Effect;
  28966. /**
  28967. * Sets a float4 on a uniform variable.
  28968. * @param uniformName Name of the variable.
  28969. * @param x First float in float4.
  28970. * @param y Second float in float4.
  28971. * @param z Third float in float4.
  28972. * @param w Fourth float in float4.
  28973. * @returns this effect.
  28974. */
  28975. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28976. /**
  28977. * Sets a Color3 on a uniform variable.
  28978. * @param uniformName Name of the variable.
  28979. * @param color3 Value to be set.
  28980. * @returns this effect.
  28981. */
  28982. setColor3(uniformName: string, color3: Color3): Effect;
  28983. /**
  28984. * Sets a Color4 on a uniform variable.
  28985. * @param uniformName Name of the variable.
  28986. * @param color3 Value to be set.
  28987. * @param alpha Alpha value to be set.
  28988. * @returns this effect.
  28989. */
  28990. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  28991. /**
  28992. * Sets a Color4 on a uniform variable
  28993. * @param uniformName defines the name of the variable
  28994. * @param color4 defines the value to be set
  28995. * @returns this effect.
  28996. */
  28997. setDirectColor4(uniformName: string, color4: Color4): Effect;
  28998. /** Release all associated resources */
  28999. dispose(): void;
  29000. /**
  29001. * This function will add a new shader to the shader store
  29002. * @param name the name of the shader
  29003. * @param pixelShader optional pixel shader content
  29004. * @param vertexShader optional vertex shader content
  29005. */
  29006. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29007. /**
  29008. * Store of each shader (The can be looked up using effect.key)
  29009. */
  29010. static ShadersStore: {
  29011. [key: string]: string;
  29012. };
  29013. /**
  29014. * Store of each included file for a shader (The can be looked up using effect.key)
  29015. */
  29016. static IncludesShadersStore: {
  29017. [key: string]: string;
  29018. };
  29019. /**
  29020. * Resets the cache of effects.
  29021. */
  29022. static ResetCache(): void;
  29023. }
  29024. }
  29025. declare module BABYLON {
  29026. /**
  29027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  29028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  29029. * 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;
  29030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  29031. */
  29032. export class ColorCurves {
  29033. private _dirty;
  29034. private _tempColor;
  29035. private _globalCurve;
  29036. private _highlightsCurve;
  29037. private _midtonesCurve;
  29038. private _shadowsCurve;
  29039. private _positiveCurve;
  29040. private _negativeCurve;
  29041. private _globalHue;
  29042. private _globalDensity;
  29043. private _globalSaturation;
  29044. private _globalExposure;
  29045. /**
  29046. * Gets the global Hue value.
  29047. * 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).
  29048. */
  29049. /**
  29050. * Sets the global Hue value.
  29051. * 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).
  29052. */
  29053. globalHue: number;
  29054. /**
  29055. * Gets the global Density value.
  29056. * 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.
  29057. * Values less than zero provide a filter of opposite hue.
  29058. */
  29059. /**
  29060. * Sets the global Density value.
  29061. * 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.
  29062. * Values less than zero provide a filter of opposite hue.
  29063. */
  29064. globalDensity: number;
  29065. /**
  29066. * Gets the global Saturation value.
  29067. * 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.
  29068. */
  29069. /**
  29070. * Sets the global Saturation value.
  29071. * 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.
  29072. */
  29073. globalSaturation: number;
  29074. /**
  29075. * Gets the global Exposure value.
  29076. * 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.
  29077. */
  29078. /**
  29079. * Sets the global Exposure value.
  29080. * 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.
  29081. */
  29082. globalExposure: number;
  29083. private _highlightsHue;
  29084. private _highlightsDensity;
  29085. private _highlightsSaturation;
  29086. private _highlightsExposure;
  29087. /**
  29088. * Gets the highlights Hue value.
  29089. * 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).
  29090. */
  29091. /**
  29092. * Sets the highlights Hue value.
  29093. * 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).
  29094. */
  29095. highlightsHue: number;
  29096. /**
  29097. * Gets the highlights Density value.
  29098. * 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.
  29099. * Values less than zero provide a filter of opposite hue.
  29100. */
  29101. /**
  29102. * Sets the highlights Density value.
  29103. * 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.
  29104. * Values less than zero provide a filter of opposite hue.
  29105. */
  29106. highlightsDensity: number;
  29107. /**
  29108. * Gets the highlights Saturation value.
  29109. * 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.
  29110. */
  29111. /**
  29112. * Sets the highlights Saturation value.
  29113. * 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.
  29114. */
  29115. highlightsSaturation: number;
  29116. /**
  29117. * Gets the highlights Exposure value.
  29118. * 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.
  29119. */
  29120. /**
  29121. * Sets the highlights Exposure value.
  29122. * 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.
  29123. */
  29124. highlightsExposure: number;
  29125. private _midtonesHue;
  29126. private _midtonesDensity;
  29127. private _midtonesSaturation;
  29128. private _midtonesExposure;
  29129. /**
  29130. * Gets the midtones Hue value.
  29131. * 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).
  29132. */
  29133. /**
  29134. * Sets the midtones Hue value.
  29135. * 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).
  29136. */
  29137. midtonesHue: number;
  29138. /**
  29139. * Gets the midtones Density value.
  29140. * 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.
  29141. * Values less than zero provide a filter of opposite hue.
  29142. */
  29143. /**
  29144. * Sets the midtones Density value.
  29145. * 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.
  29146. * Values less than zero provide a filter of opposite hue.
  29147. */
  29148. midtonesDensity: number;
  29149. /**
  29150. * Gets the midtones Saturation value.
  29151. * 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.
  29152. */
  29153. /**
  29154. * Sets the midtones Saturation value.
  29155. * 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.
  29156. */
  29157. midtonesSaturation: number;
  29158. /**
  29159. * Gets the midtones Exposure value.
  29160. * 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.
  29161. */
  29162. /**
  29163. * Sets the midtones Exposure value.
  29164. * 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.
  29165. */
  29166. midtonesExposure: number;
  29167. private _shadowsHue;
  29168. private _shadowsDensity;
  29169. private _shadowsSaturation;
  29170. private _shadowsExposure;
  29171. /**
  29172. * Gets the shadows Hue value.
  29173. * 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).
  29174. */
  29175. /**
  29176. * Sets the shadows Hue value.
  29177. * 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).
  29178. */
  29179. shadowsHue: number;
  29180. /**
  29181. * Gets the shadows Density value.
  29182. * 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.
  29183. * Values less than zero provide a filter of opposite hue.
  29184. */
  29185. /**
  29186. * Sets the shadows Density value.
  29187. * 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.
  29188. * Values less than zero provide a filter of opposite hue.
  29189. */
  29190. shadowsDensity: number;
  29191. /**
  29192. * Gets the shadows Saturation value.
  29193. * 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.
  29194. */
  29195. /**
  29196. * Sets the shadows Saturation value.
  29197. * 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.
  29198. */
  29199. shadowsSaturation: number;
  29200. /**
  29201. * Gets the shadows Exposure value.
  29202. * 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.
  29203. */
  29204. /**
  29205. * Sets the shadows Exposure value.
  29206. * 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.
  29207. */
  29208. shadowsExposure: number;
  29209. /**
  29210. * Returns the class name
  29211. * @returns The class name
  29212. */
  29213. getClassName(): string;
  29214. /**
  29215. * Binds the color curves to the shader.
  29216. * @param colorCurves The color curve to bind
  29217. * @param effect The effect to bind to
  29218. * @param positiveUniform The positive uniform shader parameter
  29219. * @param neutralUniform The neutral uniform shader parameter
  29220. * @param negativeUniform The negative uniform shader parameter
  29221. */
  29222. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  29223. /**
  29224. * Prepare the list of uniforms associated with the ColorCurves effects.
  29225. * @param uniformsList The list of uniforms used in the effect
  29226. */
  29227. static PrepareUniforms(uniformsList: string[]): void;
  29228. /**
  29229. * Returns color grading data based on a hue, density, saturation and exposure value.
  29230. * @param filterHue The hue of the color filter.
  29231. * @param filterDensity The density of the color filter.
  29232. * @param saturation The saturation.
  29233. * @param exposure The exposure.
  29234. * @param result The result data container.
  29235. */
  29236. private getColorGradingDataToRef;
  29237. /**
  29238. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  29239. * @param value The input slider value in range [-100,100].
  29240. * @returns Adjusted value.
  29241. */
  29242. private static applyColorGradingSliderNonlinear;
  29243. /**
  29244. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  29245. * @param hue The hue (H) input.
  29246. * @param saturation The saturation (S) input.
  29247. * @param brightness The brightness (B) input.
  29248. * @result An RGBA color represented as Vector4.
  29249. */
  29250. private static fromHSBToRef;
  29251. /**
  29252. * Returns a value clamped between min and max
  29253. * @param value The value to clamp
  29254. * @param min The minimum of value
  29255. * @param max The maximum of value
  29256. * @returns The clamped value.
  29257. */
  29258. private static clamp;
  29259. /**
  29260. * Clones the current color curve instance.
  29261. * @return The cloned curves
  29262. */
  29263. clone(): ColorCurves;
  29264. /**
  29265. * Serializes the current color curve instance to a json representation.
  29266. * @return a JSON representation
  29267. */
  29268. serialize(): any;
  29269. /**
  29270. * Parses the color curve from a json representation.
  29271. * @param source the JSON source to parse
  29272. * @return The parsed curves
  29273. */
  29274. static Parse(source: any): ColorCurves;
  29275. }
  29276. }
  29277. declare module BABYLON {
  29278. /**
  29279. * Interface to follow in your material defines to integrate easily the
  29280. * Image proccessing functions.
  29281. * @hidden
  29282. */
  29283. export interface IImageProcessingConfigurationDefines {
  29284. IMAGEPROCESSING: boolean;
  29285. VIGNETTE: boolean;
  29286. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29287. VIGNETTEBLENDMODEOPAQUE: boolean;
  29288. TONEMAPPING: boolean;
  29289. TONEMAPPING_ACES: boolean;
  29290. CONTRAST: boolean;
  29291. EXPOSURE: boolean;
  29292. COLORCURVES: boolean;
  29293. COLORGRADING: boolean;
  29294. COLORGRADING3D: boolean;
  29295. SAMPLER3DGREENDEPTH: boolean;
  29296. SAMPLER3DBGRMAP: boolean;
  29297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29298. }
  29299. /**
  29300. * @hidden
  29301. */
  29302. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  29303. IMAGEPROCESSING: boolean;
  29304. VIGNETTE: boolean;
  29305. VIGNETTEBLENDMODEMULTIPLY: boolean;
  29306. VIGNETTEBLENDMODEOPAQUE: boolean;
  29307. TONEMAPPING: boolean;
  29308. TONEMAPPING_ACES: boolean;
  29309. CONTRAST: boolean;
  29310. COLORCURVES: boolean;
  29311. COLORGRADING: boolean;
  29312. COLORGRADING3D: boolean;
  29313. SAMPLER3DGREENDEPTH: boolean;
  29314. SAMPLER3DBGRMAP: boolean;
  29315. IMAGEPROCESSINGPOSTPROCESS: boolean;
  29316. EXPOSURE: boolean;
  29317. constructor();
  29318. }
  29319. /**
  29320. * This groups together the common properties used for image processing either in direct forward pass
  29321. * or through post processing effect depending on the use of the image processing pipeline in your scene
  29322. * or not.
  29323. */
  29324. export class ImageProcessingConfiguration {
  29325. /**
  29326. * Default tone mapping applied in BabylonJS.
  29327. */
  29328. static readonly TONEMAPPING_STANDARD: number;
  29329. /**
  29330. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  29331. * to other engines rendering to increase portability.
  29332. */
  29333. static readonly TONEMAPPING_ACES: number;
  29334. /**
  29335. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  29336. */
  29337. colorCurves: Nullable<ColorCurves>;
  29338. private _colorCurvesEnabled;
  29339. /**
  29340. * Gets wether the color curves effect is enabled.
  29341. */
  29342. /**
  29343. * Sets wether the color curves effect is enabled.
  29344. */
  29345. colorCurvesEnabled: boolean;
  29346. private _colorGradingTexture;
  29347. /**
  29348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29349. */
  29350. /**
  29351. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  29352. */
  29353. colorGradingTexture: Nullable<BaseTexture>;
  29354. private _colorGradingEnabled;
  29355. /**
  29356. * Gets wether the color grading effect is enabled.
  29357. */
  29358. /**
  29359. * Sets wether the color grading effect is enabled.
  29360. */
  29361. colorGradingEnabled: boolean;
  29362. private _colorGradingWithGreenDepth;
  29363. /**
  29364. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  29365. */
  29366. /**
  29367. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  29368. */
  29369. colorGradingWithGreenDepth: boolean;
  29370. private _colorGradingBGR;
  29371. /**
  29372. * Gets wether the color grading texture contains BGR values.
  29373. */
  29374. /**
  29375. * Sets wether the color grading texture contains BGR values.
  29376. */
  29377. colorGradingBGR: boolean;
  29378. /** @hidden */ private _exposure: number;
  29379. /**
  29380. * Gets the Exposure used in the effect.
  29381. */
  29382. /**
  29383. * Sets the Exposure used in the effect.
  29384. */
  29385. exposure: number;
  29386. private _toneMappingEnabled;
  29387. /**
  29388. * Gets wether the tone mapping effect is enabled.
  29389. */
  29390. /**
  29391. * Sets wether the tone mapping effect is enabled.
  29392. */
  29393. toneMappingEnabled: boolean;
  29394. private _toneMappingType;
  29395. /**
  29396. * Gets the type of tone mapping effect.
  29397. */
  29398. /**
  29399. * Sets the type of tone mapping effect used in BabylonJS.
  29400. */
  29401. toneMappingType: number;
  29402. protected _contrast: number;
  29403. /**
  29404. * Gets the contrast used in the effect.
  29405. */
  29406. /**
  29407. * Sets the contrast used in the effect.
  29408. */
  29409. contrast: number;
  29410. /**
  29411. * Vignette stretch size.
  29412. */
  29413. vignetteStretch: number;
  29414. /**
  29415. * Vignette centre X Offset.
  29416. */
  29417. vignetteCentreX: number;
  29418. /**
  29419. * Vignette centre Y Offset.
  29420. */
  29421. vignetteCentreY: number;
  29422. /**
  29423. * Vignette weight or intensity of the vignette effect.
  29424. */
  29425. vignetteWeight: number;
  29426. /**
  29427. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  29428. * if vignetteEnabled is set to true.
  29429. */
  29430. vignetteColor: Color4;
  29431. /**
  29432. * Camera field of view used by the Vignette effect.
  29433. */
  29434. vignetteCameraFov: number;
  29435. private _vignetteBlendMode;
  29436. /**
  29437. * Gets the vignette blend mode allowing different kind of effect.
  29438. */
  29439. /**
  29440. * Sets the vignette blend mode allowing different kind of effect.
  29441. */
  29442. vignetteBlendMode: number;
  29443. private _vignetteEnabled;
  29444. /**
  29445. * Gets wether the vignette effect is enabled.
  29446. */
  29447. /**
  29448. * Sets wether the vignette effect is enabled.
  29449. */
  29450. vignetteEnabled: boolean;
  29451. private _applyByPostProcess;
  29452. /**
  29453. * Gets wether the image processing is applied through a post process or not.
  29454. */
  29455. /**
  29456. * Sets wether the image processing is applied through a post process or not.
  29457. */
  29458. applyByPostProcess: boolean;
  29459. private _isEnabled;
  29460. /**
  29461. * Gets wether the image processing is enabled or not.
  29462. */
  29463. /**
  29464. * Sets wether the image processing is enabled or not.
  29465. */
  29466. isEnabled: boolean;
  29467. /**
  29468. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  29469. */
  29470. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  29471. /**
  29472. * Method called each time the image processing information changes requires to recompile the effect.
  29473. */
  29474. protected _updateParameters(): void;
  29475. /**
  29476. * Gets the current class name.
  29477. * @return "ImageProcessingConfiguration"
  29478. */
  29479. getClassName(): string;
  29480. /**
  29481. * Prepare the list of uniforms associated with the Image Processing effects.
  29482. * @param uniforms The list of uniforms used in the effect
  29483. * @param defines the list of defines currently in use
  29484. */
  29485. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  29486. /**
  29487. * Prepare the list of samplers associated with the Image Processing effects.
  29488. * @param samplersList The list of uniforms used in the effect
  29489. * @param defines the list of defines currently in use
  29490. */
  29491. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  29492. /**
  29493. * Prepare the list of defines associated to the shader.
  29494. * @param defines the list of defines to complete
  29495. * @param forPostProcess Define if we are currently in post process mode or not
  29496. */
  29497. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  29498. /**
  29499. * Returns true if all the image processing information are ready.
  29500. * @returns True if ready, otherwise, false
  29501. */
  29502. isReady(): boolean;
  29503. /**
  29504. * Binds the image processing to the shader.
  29505. * @param effect The effect to bind to
  29506. * @param aspectRatio Define the current aspect ratio of the effect
  29507. */
  29508. bind(effect: Effect, aspectRatio?: number): void;
  29509. /**
  29510. * Clones the current image processing instance.
  29511. * @return The cloned image processing
  29512. */
  29513. clone(): ImageProcessingConfiguration;
  29514. /**
  29515. * Serializes the current image processing instance to a json representation.
  29516. * @return a JSON representation
  29517. */
  29518. serialize(): any;
  29519. /**
  29520. * Parses the image processing from a json representation.
  29521. * @param source the JSON source to parse
  29522. * @return The parsed image processing
  29523. */
  29524. static Parse(source: any): ImageProcessingConfiguration;
  29525. private static _VIGNETTEMODE_MULTIPLY;
  29526. private static _VIGNETTEMODE_OPAQUE;
  29527. /**
  29528. * Used to apply the vignette as a mix with the pixel color.
  29529. */
  29530. static readonly VIGNETTEMODE_MULTIPLY: number;
  29531. /**
  29532. * Used to apply the vignette as a replacement of the pixel color.
  29533. */
  29534. static readonly VIGNETTEMODE_OPAQUE: number;
  29535. }
  29536. }
  29537. declare module BABYLON {
  29538. /**
  29539. * This represents all the required information to add a fresnel effect on a material:
  29540. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  29541. */
  29542. export class FresnelParameters {
  29543. private _isEnabled;
  29544. /**
  29545. * Define if the fresnel effect is enable or not.
  29546. */
  29547. isEnabled: boolean;
  29548. /**
  29549. * Define the color used on edges (grazing angle)
  29550. */
  29551. leftColor: Color3;
  29552. /**
  29553. * Define the color used on center
  29554. */
  29555. rightColor: Color3;
  29556. /**
  29557. * Define bias applied to computed fresnel term
  29558. */
  29559. bias: number;
  29560. /**
  29561. * Defined the power exponent applied to fresnel term
  29562. */
  29563. power: number;
  29564. /**
  29565. * Clones the current fresnel and its valuues
  29566. * @returns a clone fresnel configuration
  29567. */
  29568. clone(): FresnelParameters;
  29569. /**
  29570. * Serializes the current fresnel parameters to a JSON representation.
  29571. * @return the JSON serialization
  29572. */
  29573. serialize(): any;
  29574. /**
  29575. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  29576. * @param parsedFresnelParameters Define the JSON representation
  29577. * @returns the parsed parameters
  29578. */
  29579. static Parse(parsedFresnelParameters: any): FresnelParameters;
  29580. }
  29581. }
  29582. declare module BABYLON {
  29583. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  29584. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29585. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29586. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29587. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29588. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29589. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29590. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29591. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29592. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29593. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29594. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29595. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29596. /**
  29597. * Decorator used to define property that can be serialized as reference to a camera
  29598. * @param sourceName defines the name of the property to decorate
  29599. */
  29600. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  29601. /**
  29602. * Class used to help serialization objects
  29603. */
  29604. export class SerializationHelper {
  29605. /** hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  29606. /** hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  29607. /** hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  29608. /** hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  29609. /**
  29610. * Appends the serialized animations from the source animations
  29611. * @param source Source containing the animations
  29612. * @param destination Target to store the animations
  29613. */
  29614. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  29615. /**
  29616. * Static function used to serialized a specific entity
  29617. * @param entity defines the entity to serialize
  29618. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  29619. * @returns a JSON compatible object representing the serialization of the entity
  29620. */
  29621. static Serialize<T>(entity: T, serializationObject?: any): any;
  29622. /**
  29623. * Creates a new entity from a serialization data object
  29624. * @param creationFunction defines a function used to instanciated the new entity
  29625. * @param source defines the source serialization data
  29626. * @param scene defines the hosting scene
  29627. * @param rootUrl defines the root url for resources
  29628. * @returns a new entity
  29629. */
  29630. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  29631. /**
  29632. * Clones an object
  29633. * @param creationFunction defines the function used to instanciate the new object
  29634. * @param source defines the source object
  29635. * @returns the cloned object
  29636. */
  29637. static Clone<T>(creationFunction: () => T, source: T): T;
  29638. /**
  29639. * Instanciates a new object based on a source one (some data will be shared between both object)
  29640. * @param creationFunction defines the function used to instanciate the new object
  29641. * @param source defines the source object
  29642. * @returns the new object
  29643. */
  29644. static Instanciate<T>(creationFunction: () => T, source: T): T;
  29645. }
  29646. }
  29647. declare module BABYLON {
  29648. /**
  29649. * This is the base class of all the camera used in the application.
  29650. * @see http://doc.babylonjs.com/features/cameras
  29651. */
  29652. export class Camera extends Node {
  29653. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29654. /**
  29655. * This is the default projection mode used by the cameras.
  29656. * It helps recreating a feeling of perspective and better appreciate depth.
  29657. * This is the best way to simulate real life cameras.
  29658. */
  29659. static readonly PERSPECTIVE_CAMERA: number;
  29660. /**
  29661. * This helps creating camera with an orthographic mode.
  29662. * 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.
  29663. */
  29664. static readonly ORTHOGRAPHIC_CAMERA: number;
  29665. /**
  29666. * This is the default FOV mode for perspective cameras.
  29667. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29668. */
  29669. static readonly FOVMODE_VERTICAL_FIXED: number;
  29670. /**
  29671. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29672. */
  29673. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29674. /**
  29675. * This specifies ther is no need for a camera rig.
  29676. * Basically only one eye is rendered corresponding to the camera.
  29677. */
  29678. static readonly RIG_MODE_NONE: number;
  29679. /**
  29680. * Simulates a camera Rig with one blue eye and one red eye.
  29681. * This can be use with 3d blue and red glasses.
  29682. */
  29683. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29684. /**
  29685. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29686. */
  29687. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29688. /**
  29689. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29690. */
  29691. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29692. /**
  29693. * Defines that both eyes of the camera will be rendered over under each other.
  29694. */
  29695. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29696. /**
  29697. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29698. */
  29699. static readonly RIG_MODE_VR: number;
  29700. /**
  29701. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29702. */
  29703. static readonly RIG_MODE_WEBVR: number;
  29704. /**
  29705. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29706. */
  29707. static readonly RIG_MODE_CUSTOM: number;
  29708. /**
  29709. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29710. */
  29711. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29712. /**
  29713. * Define the input manager associated with the camera.
  29714. */
  29715. inputs: CameraInputsManager<Camera>;
  29716. /** @hidden */ private _position: Vector3;
  29717. /**
  29718. * Define the current local position of the camera in the scene
  29719. */
  29720. position: Vector3;
  29721. /**
  29722. * The vector the camera should consider as up.
  29723. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29724. */
  29725. upVector: Vector3;
  29726. /**
  29727. * Define the current limit on the left side for an orthographic camera
  29728. * In scene unit
  29729. */
  29730. orthoLeft: Nullable<number>;
  29731. /**
  29732. * Define the current limit on the right side for an orthographic camera
  29733. * In scene unit
  29734. */
  29735. orthoRight: Nullable<number>;
  29736. /**
  29737. * Define the current limit on the bottom side for an orthographic camera
  29738. * In scene unit
  29739. */
  29740. orthoBottom: Nullable<number>;
  29741. /**
  29742. * Define the current limit on the top side for an orthographic camera
  29743. * In scene unit
  29744. */
  29745. orthoTop: Nullable<number>;
  29746. /**
  29747. * Field Of View is set in Radians. (default is 0.8)
  29748. */
  29749. fov: number;
  29750. /**
  29751. * Define the minimum distance the camera can see from.
  29752. * This is important to note that the depth buffer are not infinite and the closer it starts
  29753. * the more your scene might encounter depth fighting issue.
  29754. */
  29755. minZ: number;
  29756. /**
  29757. * Define the maximum distance the camera can see to.
  29758. * This is important to note that the depth buffer are not infinite and the further it end
  29759. * the more your scene might encounter depth fighting issue.
  29760. */
  29761. maxZ: number;
  29762. /**
  29763. * Define the default inertia of the camera.
  29764. * This helps giving a smooth feeling to the camera movement.
  29765. */
  29766. inertia: number;
  29767. /**
  29768. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  29769. */
  29770. mode: number;
  29771. /**
  29772. * Define wether the camera is intermediate.
  29773. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29774. */
  29775. isIntermediate: boolean;
  29776. /**
  29777. * Define the viewport of the camera.
  29778. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29779. */
  29780. viewport: Viewport;
  29781. /**
  29782. * Restricts the camera to viewing objects with the same layerMask.
  29783. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29784. */
  29785. layerMask: number;
  29786. /**
  29787. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29788. */
  29789. fovMode: number;
  29790. /**
  29791. * Rig mode of the camera.
  29792. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29793. * This is normally controlled byt the camera themselves as internal use.
  29794. */
  29795. cameraRigMode: number;
  29796. /**
  29797. * Defines the distance between both "eyes" in case of a RIG
  29798. */
  29799. interaxialDistance: number;
  29800. /**
  29801. * Defines if stereoscopic rendering is done side by side or over under.
  29802. */
  29803. isStereoscopicSideBySide: boolean;
  29804. /**
  29805. * 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
  29806. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29807. * else in the scene.
  29808. */
  29809. customRenderTargets: RenderTargetTexture[];
  29810. /**
  29811. * When set, the camera will render to this render target instead of the default canvas
  29812. */
  29813. outputRenderTarget: Nullable<RenderTargetTexture>;
  29814. /**
  29815. * Observable triggered when the camera view matrix has changed.
  29816. */
  29817. onViewMatrixChangedObservable: Observable<Camera>;
  29818. /**
  29819. * Observable triggered when the camera Projection matrix has changed.
  29820. */
  29821. onProjectionMatrixChangedObservable: Observable<Camera>;
  29822. /**
  29823. * Observable triggered when the inputs have been processed.
  29824. */
  29825. onAfterCheckInputsObservable: Observable<Camera>;
  29826. /**
  29827. * Observable triggered when reset has been called and applied to the camera.
  29828. */
  29829. onRestoreStateObservable: Observable<Camera>;
  29830. /** @hidden */ private _cameraRigParams: any;
  29831. /** @hidden */ private _rigCameras: Camera[];
  29832. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  29833. protected _webvrViewMatrix: Matrix;
  29834. /** @hidden */ private _skipRendering: boolean;
  29835. /** @hidden */ private _projectionMatrix: Matrix;
  29836. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  29837. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  29838. protected _globalPosition: Vector3;
  29839. /** hidden */ private _computedViewMatrix: Matrix;
  29840. private _doNotComputeProjectionMatrix;
  29841. private _transformMatrix;
  29842. private _frustumPlanes;
  29843. private _refreshFrustumPlanes;
  29844. private _storedFov;
  29845. private _stateStored;
  29846. /**
  29847. * Instantiates a new camera object.
  29848. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29849. * @see http://doc.babylonjs.com/features/cameras
  29850. * @param name Defines the name of the camera in the scene
  29851. * @param position Defines the position of the camera
  29852. * @param scene Defines the scene the camera belongs too
  29853. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29854. */
  29855. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29856. /**
  29857. * Store current camera state (fov, position, etc..)
  29858. * @returns the camera
  29859. */
  29860. storeState(): Camera;
  29861. /**
  29862. * Restores the camera state values if it has been stored. You must call storeState() first
  29863. */
  29864. protected _restoreStateValues(): boolean;
  29865. /**
  29866. * Restored camera state. You must call storeState() first.
  29867. * @returns true if restored and false otherwise
  29868. */
  29869. restoreState(): boolean;
  29870. /**
  29871. * Gets the class name of the camera.
  29872. * @returns the class name
  29873. */
  29874. getClassName(): string;
  29875. /** @hidden */ protected readonly _isCamera: boolean;
  29876. /**
  29877. * Gets a string representation of the camera useful for debug purpose.
  29878. * @param fullDetails Defines that a more verboe level of logging is required
  29879. * @returns the string representation
  29880. */
  29881. toString(fullDetails?: boolean): string;
  29882. /**
  29883. * Gets the current world space position of the camera.
  29884. */
  29885. readonly globalPosition: Vector3;
  29886. /**
  29887. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29888. * @returns the active meshe list
  29889. */
  29890. getActiveMeshes(): SmartArray<AbstractMesh>;
  29891. /**
  29892. * Check wether a mesh is part of the current active mesh list of the camera
  29893. * @param mesh Defines the mesh to check
  29894. * @returns true if active, false otherwise
  29895. */
  29896. isActiveMesh(mesh: Mesh): boolean;
  29897. /**
  29898. * Is this camera ready to be used/rendered
  29899. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29900. * @return true if the camera is ready
  29901. */
  29902. isReady(completeCheck?: boolean): boolean;
  29903. /** @hidden */ private _initCache(): void;
  29904. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  29905. /** @hidden */ private _isSynchronized(): boolean;
  29906. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  29907. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  29908. /**
  29909. * Attach the input controls to a specific dom element to get the input from.
  29910. * @param element Defines the element the controls should be listened from
  29911. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29912. */
  29913. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29914. /**
  29915. * Detach the current controls from the specified dom element.
  29916. * @param element Defines the element to stop listening the inputs from
  29917. */
  29918. detachControl(element: HTMLElement): void;
  29919. /**
  29920. * Update the camera state according to the different inputs gathered during the frame.
  29921. */
  29922. update(): void;
  29923. /** @hidden */ private _checkInputs(): void;
  29924. /** @hidden */
  29925. readonly rigCameras: Camera[];
  29926. /**
  29927. * Gets the post process used by the rig cameras
  29928. */
  29929. readonly rigPostProcess: Nullable<PostProcess>;
  29930. /**
  29931. * Internal, gets the first post proces.
  29932. * @returns the first post process to be run on this camera.
  29933. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  29934. private _cascadePostProcessesToRigCams;
  29935. /**
  29936. * Attach a post process to the camera.
  29937. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29938. * @param postProcess The post process to attach to the camera
  29939. * @param insertAt The position of the post process in case several of them are in use in the scene
  29940. * @returns the position the post process has been inserted at
  29941. */
  29942. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29943. /**
  29944. * Detach a post process to the camera.
  29945. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29946. * @param postProcess The post process to detach from the camera
  29947. */
  29948. detachPostProcess(postProcess: PostProcess): void;
  29949. /**
  29950. * Gets the current world matrix of the camera
  29951. */
  29952. getWorldMatrix(): Matrix;
  29953. /** @hidden */ private _getViewMatrix(): Matrix;
  29954. /**
  29955. * Gets the current view matrix of the camera.
  29956. * @param force forces the camera to recompute the matrix without looking at the cached state
  29957. * @returns the view matrix
  29958. */
  29959. getViewMatrix(force?: boolean): Matrix;
  29960. /**
  29961. * Freeze the projection matrix.
  29962. * It will prevent the cache check of the camera projection compute and can speed up perf
  29963. * if no parameter of the camera are meant to change
  29964. * @param projection Defines manually a projection if necessary
  29965. */
  29966. freezeProjectionMatrix(projection?: Matrix): void;
  29967. /**
  29968. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29969. */
  29970. unfreezeProjectionMatrix(): void;
  29971. /**
  29972. * Gets the current projection matrix of the camera.
  29973. * @param force forces the camera to recompute the matrix without looking at the cached state
  29974. * @returns the projection matrix
  29975. */
  29976. getProjectionMatrix(force?: boolean): Matrix;
  29977. /**
  29978. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29979. * @returns a Matrix
  29980. */
  29981. getTransformationMatrix(): Matrix;
  29982. private _updateFrustumPlanes;
  29983. /**
  29984. * Checks if a cullable object (mesh...) is in the camera frustum
  29985. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29986. * @param target The object to check
  29987. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29988. * @returns true if the object is in frustum otherwise false
  29989. */
  29990. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29991. /**
  29992. * Checks if a cullable object (mesh...) is in the camera frustum
  29993. * Unlike isInFrustum this cheks the full bounding box
  29994. * @param target The object to check
  29995. * @returns true if the object is in frustum otherwise false
  29996. */
  29997. isCompletelyInFrustum(target: ICullable): boolean;
  29998. /**
  29999. * Gets a ray in the forward direction from the camera.
  30000. * @param length Defines the length of the ray to create
  30001. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30002. * @param origin Defines the start point of the ray which defaults to the camera position
  30003. * @returns the forward ray
  30004. */
  30005. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30006. /**
  30007. * Releases resources associated with this node.
  30008. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30009. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30010. */
  30011. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30012. /** @hidden */ private _isLeftCamera: boolean;
  30013. /**
  30014. * Gets the left camera of a rig setup in case of Rigged Camera
  30015. */
  30016. readonly isLeftCamera: boolean;
  30017. /** @hidden */ private _isRightCamera: boolean;
  30018. /**
  30019. * Gets the right camera of a rig setup in case of Rigged Camera
  30020. */
  30021. readonly isRightCamera: boolean;
  30022. /**
  30023. * Gets the left camera of a rig setup in case of Rigged Camera
  30024. */
  30025. readonly leftCamera: Nullable<FreeCamera>;
  30026. /**
  30027. * Gets the right camera of a rig setup in case of Rigged Camera
  30028. */
  30029. readonly rightCamera: Nullable<FreeCamera>;
  30030. /**
  30031. * Gets the left camera target of a rig setup in case of Rigged Camera
  30032. * @returns the target position
  30033. */
  30034. getLeftTarget(): Nullable<Vector3>;
  30035. /**
  30036. * Gets the right camera target of a rig setup in case of Rigged Camera
  30037. * @returns the target position
  30038. */
  30039. getRightTarget(): Nullable<Vector3>;
  30040. /**
  30041. * @hidden
  30042. */
  30043. setCameraRigMode(mode: number, rigParams: any): void;
  30044. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  30045. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30046. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  30047. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30048. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  30049. protected _updateCameraRotationMatrix(): void;
  30050. protected _updateWebVRCameraRotationMatrix(): void;
  30051. /**
  30052. * This function MUST be overwritten by the different WebVR cameras available.
  30053. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30054. * @hidden
  30055. */ private _getWebVRProjectionMatrix(): Matrix;
  30056. /**
  30057. * This function MUST be overwritten by the different WebVR cameras available.
  30058. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30059. * @hidden
  30060. */ private _getWebVRViewMatrix(): Matrix;
  30061. /** @hidden */
  30062. setCameraRigParameter(name: string, value: any): void;
  30063. /**
  30064. * needs to be overridden by children so sub has required properties to be copied
  30065. * @hidden
  30066. */
  30067. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30068. /**
  30069. * May need to be overridden by children
  30070. * @hidden
  30071. */ private _updateRigCameras(): void;
  30072. /** @hidden */ private _setupInputs(): void;
  30073. /**
  30074. * Serialiaze the camera setup to a json represention
  30075. * @returns the JSON representation
  30076. */
  30077. serialize(): any;
  30078. /**
  30079. * Clones the current camera.
  30080. * @param name The cloned camera name
  30081. * @returns the cloned camera
  30082. */
  30083. clone(name: string): Camera;
  30084. /**
  30085. * Gets the direction of the camera relative to a given local axis.
  30086. * @param localAxis Defines the reference axis to provide a relative direction.
  30087. * @return the direction
  30088. */
  30089. getDirection(localAxis: Vector3): Vector3;
  30090. /**
  30091. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30092. * @param localAxis Defines the reference axis to provide a relative direction.
  30093. * @param result Defines the vector to store the result in
  30094. */
  30095. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30096. /**
  30097. * Gets a camera constructor for a given camera type
  30098. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30099. * @param name The name of the camera the result will be able to instantiate
  30100. * @param scene The scene the result will construct the camera in
  30101. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30102. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30103. * @returns a factory method to construc the camera
  30104. */
  30105. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30106. /**
  30107. * Compute the world matrix of the camera.
  30108. * @returns the camera workd matrix
  30109. */
  30110. computeWorldMatrix(): Matrix;
  30111. /**
  30112. * Parse a JSON and creates the camera from the parsed information
  30113. * @param parsedCamera The JSON to parse
  30114. * @param scene The scene to instantiate the camera in
  30115. * @returns the newly constructed camera
  30116. */
  30117. static Parse(parsedCamera: any, scene: Scene): Camera;
  30118. }
  30119. }
  30120. declare module BABYLON {
  30121. /**
  30122. * Interface for any object that can request an animation frame
  30123. */
  30124. export interface ICustomAnimationFrameRequester {
  30125. /**
  30126. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  30127. */
  30128. renderFunction?: Function;
  30129. /**
  30130. * Called to request the next frame to render to
  30131. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  30132. */
  30133. requestAnimationFrame: Function;
  30134. /**
  30135. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  30136. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  30137. */
  30138. requestID?: number;
  30139. }
  30140. /**
  30141. * Interface containing an array of animations
  30142. */
  30143. export interface IAnimatable {
  30144. /**
  30145. * Array of animations
  30146. */
  30147. animations: Nullable<Array<Animation>>;
  30148. }
  30149. /** Interface used by value gradients (color, factor, ...) */
  30150. export interface IValueGradient {
  30151. /**
  30152. * Gets or sets the gradient value (between 0 and 1)
  30153. */
  30154. gradient: number;
  30155. }
  30156. /** Class used to store color4 gradient */
  30157. export class ColorGradient implements IValueGradient {
  30158. /**
  30159. * Gets or sets the gradient value (between 0 and 1)
  30160. */
  30161. gradient: number;
  30162. /**
  30163. * Gets or sets first associated color
  30164. */
  30165. color1: Color4;
  30166. /**
  30167. * Gets or sets second associated color
  30168. */
  30169. color2?: Color4;
  30170. /**
  30171. * Will get a color picked randomly between color1 and color2.
  30172. * If color2 is undefined then color1 will be used
  30173. * @param result defines the target Color4 to store the result in
  30174. */
  30175. getColorToRef(result: Color4): void;
  30176. }
  30177. /** Class used to store color 3 gradient */
  30178. export class Color3Gradient implements IValueGradient {
  30179. /**
  30180. * Gets or sets the gradient value (between 0 and 1)
  30181. */
  30182. gradient: number;
  30183. /**
  30184. * Gets or sets the associated color
  30185. */
  30186. color: Color3;
  30187. }
  30188. /** Class used to store factor gradient */
  30189. export class FactorGradient implements IValueGradient {
  30190. /**
  30191. * Gets or sets the gradient value (between 0 and 1)
  30192. */
  30193. gradient: number;
  30194. /**
  30195. * Gets or sets first associated factor
  30196. */
  30197. factor1: number;
  30198. /**
  30199. * Gets or sets second associated factor
  30200. */
  30201. factor2?: number;
  30202. /**
  30203. * Will get a number picked randomly between factor1 and factor2.
  30204. * If factor2 is undefined then factor1 will be used
  30205. * @returns the picked number
  30206. */
  30207. getFactor(): number;
  30208. }
  30209. /**
  30210. * @ignore
  30211. * Application error to support additional information when loading a file
  30212. */
  30213. export class LoadFileError extends Error {
  30214. /** defines the optional web request */
  30215. request?: WebRequest | undefined;
  30216. private static _setPrototypeOf;
  30217. /**
  30218. * Creates a new LoadFileError
  30219. * @param message defines the message of the error
  30220. * @param request defines the optional web request
  30221. */
  30222. constructor(message: string,
  30223. /** defines the optional web request */
  30224. request?: WebRequest | undefined);
  30225. }
  30226. /**
  30227. * Class used to define a retry strategy when error happens while loading assets
  30228. */
  30229. export class RetryStrategy {
  30230. /**
  30231. * Function used to defines an exponential back off strategy
  30232. * @param maxRetries defines the maximum number of retries (3 by default)
  30233. * @param baseInterval defines the interval between retries
  30234. * @returns the strategy function to use
  30235. */
  30236. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  30237. }
  30238. /**
  30239. * File request interface
  30240. */
  30241. export interface IFileRequest {
  30242. /**
  30243. * Raised when the request is complete (success or error).
  30244. */
  30245. onCompleteObservable: Observable<IFileRequest>;
  30246. /**
  30247. * Aborts the request for a file.
  30248. */
  30249. abort: () => void;
  30250. }
  30251. /**
  30252. * Class containing a set of static utilities functions
  30253. */
  30254. export class Tools {
  30255. /**
  30256. * Gets or sets the base URL to use to load assets
  30257. */
  30258. static BaseUrl: string;
  30259. /**
  30260. * Enable/Disable Custom HTTP Request Headers globally.
  30261. * default = false
  30262. * @see CustomRequestHeaders
  30263. */
  30264. static UseCustomRequestHeaders: boolean;
  30265. /**
  30266. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  30267. * i.e. when loading files, where the server/service expects an Authorization header
  30268. */
  30269. static CustomRequestHeaders: {
  30270. [key: string]: string;
  30271. };
  30272. /**
  30273. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  30274. */
  30275. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  30276. /**
  30277. * Default behaviour for cors in the application.
  30278. * It can be a string if the expected behavior is identical in the entire app.
  30279. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  30280. */
  30281. static CorsBehavior: string | ((url: string | string[]) => string);
  30282. /**
  30283. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30284. * @ignorenaming
  30285. */
  30286. static UseFallbackTexture: boolean;
  30287. /**
  30288. * Use this object to register external classes like custom textures or material
  30289. * to allow the laoders to instantiate them
  30290. */
  30291. static RegisteredExternalClasses: {
  30292. [key: string]: Object;
  30293. };
  30294. /**
  30295. * Texture content used if a texture cannot loaded
  30296. * @ignorenaming
  30297. */
  30298. static fallbackTexture: string;
  30299. /**
  30300. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  30301. * @param u defines the coordinate on X axis
  30302. * @param v defines the coordinate on Y axis
  30303. * @param width defines the width of the source data
  30304. * @param height defines the height of the source data
  30305. * @param pixels defines the source byte array
  30306. * @param color defines the output color
  30307. */
  30308. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  30309. /**
  30310. * Interpolates between a and b via alpha
  30311. * @param a The lower value (returned when alpha = 0)
  30312. * @param b The upper value (returned when alpha = 1)
  30313. * @param alpha The interpolation-factor
  30314. * @return The mixed value
  30315. */
  30316. static Mix(a: number, b: number, alpha: number): number;
  30317. /**
  30318. * Tries to instantiate a new object from a given class name
  30319. * @param className defines the class name to instantiate
  30320. * @returns the new object or null if the system was not able to do the instantiation
  30321. */
  30322. static Instantiate(className: string): any;
  30323. /**
  30324. * Provides a slice function that will work even on IE
  30325. * @param data defines the array to slice
  30326. * @param start defines the start of the data (optional)
  30327. * @param end defines the end of the data (optional)
  30328. * @returns the new sliced array
  30329. */
  30330. static Slice<T>(data: T, start?: number, end?: number): T;
  30331. /**
  30332. * Polyfill for setImmediate
  30333. * @param action defines the action to execute after the current execution block
  30334. */
  30335. static SetImmediate(action: () => void): void;
  30336. /**
  30337. * Function indicating if a number is an exponent of 2
  30338. * @param value defines the value to test
  30339. * @returns true if the value is an exponent of 2
  30340. */
  30341. static IsExponentOfTwo(value: number): boolean;
  30342. private static _tmpFloatArray;
  30343. /**
  30344. * Returns the nearest 32-bit single precision float representation of a Number
  30345. * @param value A Number. If the parameter is of a different type, it will get converted
  30346. * to a number or to NaN if it cannot be converted
  30347. * @returns number
  30348. */
  30349. static FloatRound(value: number): number;
  30350. /**
  30351. * Find the next highest power of two.
  30352. * @param x Number to start search from.
  30353. * @return Next highest power of two.
  30354. */
  30355. static CeilingPOT(x: number): number;
  30356. /**
  30357. * Find the next lowest power of two.
  30358. * @param x Number to start search from.
  30359. * @return Next lowest power of two.
  30360. */
  30361. static FloorPOT(x: number): number;
  30362. /**
  30363. * Find the nearest power of two.
  30364. * @param x Number to start search from.
  30365. * @return Next nearest power of two.
  30366. */
  30367. static NearestPOT(x: number): number;
  30368. /**
  30369. * Get the closest exponent of two
  30370. * @param value defines the value to approximate
  30371. * @param max defines the maximum value to return
  30372. * @param mode defines how to define the closest value
  30373. * @returns closest exponent of two of the given value
  30374. */
  30375. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30376. /**
  30377. * Extracts the filename from a path
  30378. * @param path defines the path to use
  30379. * @returns the filename
  30380. */
  30381. static GetFilename(path: string): string;
  30382. /**
  30383. * Extracts the "folder" part of a path (everything before the filename).
  30384. * @param uri The URI to extract the info from
  30385. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  30386. * @returns The "folder" part of the path
  30387. */
  30388. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  30389. /**
  30390. * Extracts text content from a DOM element hierarchy
  30391. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  30392. */
  30393. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  30394. /**
  30395. * Convert an angle in radians to degrees
  30396. * @param angle defines the angle to convert
  30397. * @returns the angle in degrees
  30398. */
  30399. static ToDegrees(angle: number): number;
  30400. /**
  30401. * Convert an angle in degrees to radians
  30402. * @param angle defines the angle to convert
  30403. * @returns the angle in radians
  30404. */
  30405. static ToRadians(angle: number): number;
  30406. /**
  30407. * Encode a buffer to a base64 string
  30408. * @param buffer defines the buffer to encode
  30409. * @returns the encoded string
  30410. */
  30411. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  30412. /**
  30413. * Extracts minimum and maximum values from a list of indexed positions
  30414. * @param positions defines the positions to use
  30415. * @param indices defines the indices to the positions
  30416. * @param indexStart defines the start index
  30417. * @param indexCount defines the end index
  30418. * @param bias defines bias value to add to the result
  30419. * @return minimum and maximum values
  30420. */
  30421. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  30422. minimum: Vector3;
  30423. maximum: Vector3;
  30424. };
  30425. /**
  30426. * Extracts minimum and maximum values from a list of positions
  30427. * @param positions defines the positions to use
  30428. * @param start defines the start index in the positions array
  30429. * @param count defines the number of positions to handle
  30430. * @param bias defines bias value to add to the result
  30431. * @param stride defines the stride size to use (distance between two positions in the positions array)
  30432. * @return minimum and maximum values
  30433. */
  30434. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  30435. minimum: Vector3;
  30436. maximum: Vector3;
  30437. };
  30438. /**
  30439. * Returns an array if obj is not an array
  30440. * @param obj defines the object to evaluate as an array
  30441. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  30442. * @returns either obj directly if obj is an array or a new array containing obj
  30443. */
  30444. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  30445. /**
  30446. * Gets the pointer prefix to use
  30447. * @returns "pointer" if touch is enabled. Else returns "mouse"
  30448. */
  30449. static GetPointerPrefix(): string;
  30450. /**
  30451. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30452. * @param func - the function to be called
  30453. * @param requester - the object that will request the next frame. Falls back to window.
  30454. * @returns frame number
  30455. */
  30456. static QueueNewFrame(func: () => void, requester?: any): number;
  30457. /**
  30458. * Ask the browser to promote the current element to fullscreen rendering mode
  30459. * @param element defines the DOM element to promote
  30460. */
  30461. static RequestFullscreen(element: HTMLElement): void;
  30462. /**
  30463. * Asks the browser to exit fullscreen mode
  30464. */
  30465. static ExitFullscreen(): void;
  30466. /**
  30467. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  30468. * @param url define the url we are trying
  30469. * @param element define the dom element where to configure the cors policy
  30470. */
  30471. static SetCorsBehavior(url: string | string[], element: {
  30472. crossOrigin: string | null;
  30473. }): void;
  30474. /**
  30475. * Removes unwanted characters from an url
  30476. * @param url defines the url to clean
  30477. * @returns the cleaned url
  30478. */
  30479. static CleanUrl(url: string): string;
  30480. /**
  30481. * Gets or sets a function used to pre-process url before using them to load assets
  30482. */
  30483. static PreprocessUrl: (url: string) => string;
  30484. /**
  30485. * Loads an image as an HTMLImageElement.
  30486. * @param input url string, ArrayBuffer, or Blob to load
  30487. * @param onLoad callback called when the image successfully loads
  30488. * @param onError callback called when the image fails to load
  30489. * @param offlineProvider offline provider for caching
  30490. * @returns the HTMLImageElement of the loaded image
  30491. */
  30492. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  30493. /**
  30494. * Loads a file
  30495. * @param url url string, ArrayBuffer, or Blob to load
  30496. * @param onSuccess callback called when the file successfully loads
  30497. * @param onProgress callback called while file is loading (if the server supports this mode)
  30498. * @param offlineProvider defines the offline provider for caching
  30499. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  30500. * @param onError callback called when the file fails to load
  30501. * @returns a file request object
  30502. */
  30503. 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;
  30504. /**
  30505. * Load a script (identified by an url). When the url returns, the
  30506. * content of this file is added into a new script element, attached to the DOM (body element)
  30507. * @param scriptUrl defines the url of the script to laod
  30508. * @param onSuccess defines the callback called when the script is loaded
  30509. * @param onError defines the callback to call if an error occurs
  30510. * @param scriptId defines the id of the script element
  30511. */
  30512. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  30513. /**
  30514. * Load an asynchronous script (identified by an url). When the url returns, the
  30515. * content of this file is added into a new script element, attached to the DOM (body element)
  30516. * @param scriptUrl defines the url of the script to laod
  30517. * @param scriptId defines the id of the script element
  30518. * @returns a promise request object
  30519. */
  30520. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  30521. /**
  30522. * Loads a file from a blob
  30523. * @param fileToLoad defines the blob to use
  30524. * @param callback defines the callback to call when data is loaded
  30525. * @param progressCallback defines the callback to call during loading process
  30526. * @returns a file request object
  30527. */
  30528. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  30529. /**
  30530. * Loads a file
  30531. * @param fileToLoad defines the file to load
  30532. * @param callback defines the callback to call when data is loaded
  30533. * @param progressCallBack defines the callback to call during loading process
  30534. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  30535. * @returns a file request object
  30536. */
  30537. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  30538. /**
  30539. * Creates a data url from a given string content
  30540. * @param content defines the content to convert
  30541. * @returns the new data url link
  30542. */
  30543. static FileAsURL(content: string): string;
  30544. /**
  30545. * Format the given number to a specific decimal format
  30546. * @param value defines the number to format
  30547. * @param decimals defines the number of decimals to use
  30548. * @returns the formatted string
  30549. */
  30550. static Format(value: number, decimals?: number): string;
  30551. /**
  30552. * Checks if a given vector is inside a specific range
  30553. * @param v defines the vector to test
  30554. * @param min defines the minimum range
  30555. * @param max defines the maximum range
  30556. */
  30557. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  30558. /**
  30559. * Tries to copy an object by duplicating every property
  30560. * @param source defines the source object
  30561. * @param destination defines the target object
  30562. * @param doNotCopyList defines a list of properties to avoid
  30563. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  30564. */
  30565. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  30566. /**
  30567. * Gets a boolean indicating if the given object has no own property
  30568. * @param obj defines the object to test
  30569. * @returns true if object has no own property
  30570. */
  30571. static IsEmpty(obj: any): boolean;
  30572. /**
  30573. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  30574. * @param str Source string
  30575. * @param suffix Suffix to search for in the source string
  30576. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  30577. */
  30578. static EndsWith(str: string, suffix: string): boolean;
  30579. /**
  30580. * Function used to register events at window level
  30581. * @param events defines the events to register
  30582. */
  30583. static RegisterTopRootEvents(events: {
  30584. name: string;
  30585. handler: Nullable<(e: FocusEvent) => any>;
  30586. }[]): void;
  30587. /**
  30588. * Function used to unregister events from window level
  30589. * @param events defines the events to unregister
  30590. */
  30591. static UnregisterTopRootEvents(events: {
  30592. name: string;
  30593. handler: Nullable<(e: FocusEvent) => any>;
  30594. }[]): void;
  30595. /**
  30596. * @ignore
  30597. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  30598. /**
  30599. * Dumps the current bound framebuffer
  30600. * @param width defines the rendering width
  30601. * @param height defines the rendering height
  30602. * @param engine defines the hosting engine
  30603. * @param successCallback defines the callback triggered once the data are available
  30604. * @param mimeType defines the mime type of the result
  30605. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  30606. */
  30607. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30608. /**
  30609. * Converts the canvas data to blob.
  30610. * This acts as a polyfill for browsers not supporting the to blob function.
  30611. * @param canvas Defines the canvas to extract the data from
  30612. * @param successCallback Defines the callback triggered once the data are available
  30613. * @param mimeType Defines the mime type of the result
  30614. */
  30615. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  30616. /**
  30617. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  30618. * @param successCallback defines the callback triggered once the data are available
  30619. * @param mimeType defines the mime type of the result
  30620. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  30621. */
  30622. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  30623. /**
  30624. * Downloads a blob in the browser
  30625. * @param blob defines the blob to download
  30626. * @param fileName defines the name of the downloaded file
  30627. */
  30628. static Download(blob: Blob, fileName: string): void;
  30629. /**
  30630. * Captures a screenshot of the current rendering
  30631. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30632. * @param engine defines the rendering engine
  30633. * @param camera defines the source camera
  30634. * @param size This parameter can be set to a single number or to an object with the
  30635. * following (optional) properties: precision, width, height. If a single number is passed,
  30636. * it will be used for both width and height. If an object is passed, the screenshot size
  30637. * will be derived from the parameters. The precision property is a multiplier allowing
  30638. * rendering at a higher or lower resolution
  30639. * @param successCallback defines the callback receives a single parameter which contains the
  30640. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30641. * src parameter of an <img> to display it
  30642. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  30643. * Check your browser for supported MIME types
  30644. */
  30645. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  30646. /**
  30647. * Generates an image screenshot from the specified camera.
  30648. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  30649. * @param engine The engine to use for rendering
  30650. * @param camera The camera to use for rendering
  30651. * @param size This parameter can be set to a single number or to an object with the
  30652. * following (optional) properties: precision, width, height. If a single number is passed,
  30653. * it will be used for both width and height. If an object is passed, the screenshot size
  30654. * will be derived from the parameters. The precision property is a multiplier allowing
  30655. * rendering at a higher or lower resolution
  30656. * @param successCallback The callback receives a single parameter which contains the
  30657. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  30658. * src parameter of an <img> to display it
  30659. * @param mimeType The MIME type of the screenshot image (default: image/png).
  30660. * Check your browser for supported MIME types
  30661. * @param samples Texture samples (default: 1)
  30662. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  30663. * @param fileName A name for for the downloaded file.
  30664. */
  30665. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  30666. /**
  30667. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30668. * Be aware Math.random() could cause collisions, but:
  30669. * "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"
  30670. * @returns a pseudo random id
  30671. */
  30672. static RandomId(): string;
  30673. /**
  30674. * Test if the given uri is a base64 string
  30675. * @param uri The uri to test
  30676. * @return True if the uri is a base64 string or false otherwise
  30677. */
  30678. static IsBase64(uri: string): boolean;
  30679. /**
  30680. * Decode the given base64 uri.
  30681. * @param uri The uri to decode
  30682. * @return The decoded base64 data.
  30683. */
  30684. static DecodeBase64(uri: string): ArrayBuffer;
  30685. /**
  30686. * Gets the absolute url.
  30687. * @param url the input url
  30688. * @return the absolute url
  30689. */
  30690. static GetAbsoluteUrl(url: string): string;
  30691. /**
  30692. * No log
  30693. */
  30694. static readonly NoneLogLevel: number;
  30695. /**
  30696. * Only message logs
  30697. */
  30698. static readonly MessageLogLevel: number;
  30699. /**
  30700. * Only warning logs
  30701. */
  30702. static readonly WarningLogLevel: number;
  30703. /**
  30704. * Only error logs
  30705. */
  30706. static readonly ErrorLogLevel: number;
  30707. /**
  30708. * All logs
  30709. */
  30710. static readonly AllLogLevel: number;
  30711. /**
  30712. * Gets a value indicating the number of loading errors
  30713. * @ignorenaming
  30714. */
  30715. static readonly errorsCount: number;
  30716. /**
  30717. * Callback called when a new log is added
  30718. */
  30719. static OnNewCacheEntry: (entry: string) => void;
  30720. /**
  30721. * Log a message to the console
  30722. * @param message defines the message to log
  30723. */
  30724. static Log(message: string): void;
  30725. /**
  30726. * Write a warning message to the console
  30727. * @param message defines the message to log
  30728. */
  30729. static Warn(message: string): void;
  30730. /**
  30731. * Write an error message to the console
  30732. * @param message defines the message to log
  30733. */
  30734. static Error(message: string): void;
  30735. /**
  30736. * Gets current log cache (list of logs)
  30737. */
  30738. static readonly LogCache: string;
  30739. /**
  30740. * Clears the log cache
  30741. */
  30742. static ClearLogCache(): void;
  30743. /**
  30744. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  30745. */
  30746. static LogLevels: number;
  30747. /**
  30748. * Checks if the loaded document was accessed via `file:`-Protocol.
  30749. * @returns boolean
  30750. */
  30751. static IsFileURL(): boolean;
  30752. /**
  30753. * Checks if the window object exists
  30754. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  30755. */
  30756. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  30757. /**
  30758. * No performance log
  30759. */
  30760. static readonly PerformanceNoneLogLevel: number;
  30761. /**
  30762. * Use user marks to log performance
  30763. */
  30764. static readonly PerformanceUserMarkLogLevel: number;
  30765. /**
  30766. * Log performance to the console
  30767. */
  30768. static readonly PerformanceConsoleLogLevel: number;
  30769. private static _performance;
  30770. /**
  30771. * Sets the current performance log level
  30772. */
  30773. static PerformanceLogLevel: number;
  30774. private static _StartPerformanceCounterDisabled;
  30775. private static _EndPerformanceCounterDisabled;
  30776. private static _StartUserMark;
  30777. private static _EndUserMark;
  30778. private static _StartPerformanceConsole;
  30779. private static _EndPerformanceConsole;
  30780. /**
  30781. * Starts a performance counter
  30782. */
  30783. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30784. /**
  30785. * Ends a specific performance coutner
  30786. */
  30787. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  30788. /**
  30789. * Gets either window.performance.now() if supported or Date.now() else
  30790. */
  30791. static readonly Now: number;
  30792. /**
  30793. * This method will return the name of the class used to create the instance of the given object.
  30794. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  30795. * @param object the object to get the class name from
  30796. * @param isType defines if the object is actually a type
  30797. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  30798. */
  30799. static GetClassName(object: any, isType?: boolean): string;
  30800. /**
  30801. * Gets the first element of an array satisfying a given predicate
  30802. * @param array defines the array to browse
  30803. * @param predicate defines the predicate to use
  30804. * @returns null if not found or the element
  30805. */
  30806. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  30807. /**
  30808. * This method will return the name of the full name of the class, including its owning module (if any).
  30809. * 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).
  30810. * @param object the object to get the class name from
  30811. * @param isType defines if the object is actually a type
  30812. * @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.
  30813. * @ignorenaming
  30814. */
  30815. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  30816. /**
  30817. * Returns a promise that resolves after the given amount of time.
  30818. * @param delay Number of milliseconds to delay
  30819. * @returns Promise that resolves after the given amount of time
  30820. */
  30821. static DelayAsync(delay: number): Promise<void>;
  30822. /**
  30823. * Gets the current gradient from an array of IValueGradient
  30824. * @param ratio defines the current ratio to get
  30825. * @param gradients defines the array of IValueGradient
  30826. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  30827. */
  30828. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  30829. }
  30830. /**
  30831. * This class is used to track a performance counter which is number based.
  30832. * The user has access to many properties which give statistics of different nature.
  30833. *
  30834. * The implementer can track two kinds of Performance Counter: time and count.
  30835. * 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.
  30836. * 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.
  30837. */
  30838. export class PerfCounter {
  30839. /**
  30840. * Gets or sets a global boolean to turn on and off all the counters
  30841. */
  30842. static Enabled: boolean;
  30843. /**
  30844. * Returns the smallest value ever
  30845. */
  30846. readonly min: number;
  30847. /**
  30848. * Returns the biggest value ever
  30849. */
  30850. readonly max: number;
  30851. /**
  30852. * Returns the average value since the performance counter is running
  30853. */
  30854. readonly average: number;
  30855. /**
  30856. * Returns the average value of the last second the counter was monitored
  30857. */
  30858. readonly lastSecAverage: number;
  30859. /**
  30860. * Returns the current value
  30861. */
  30862. readonly current: number;
  30863. /**
  30864. * Gets the accumulated total
  30865. */
  30866. readonly total: number;
  30867. /**
  30868. * Gets the total value count
  30869. */
  30870. readonly count: number;
  30871. /**
  30872. * Creates a new counter
  30873. */
  30874. constructor();
  30875. /**
  30876. * Call this method to start monitoring a new frame.
  30877. * 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.
  30878. */
  30879. fetchNewFrame(): void;
  30880. /**
  30881. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  30882. * @param newCount the count value to add to the monitored count
  30883. * @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.
  30884. */
  30885. addCount(newCount: number, fetchResult: boolean): void;
  30886. /**
  30887. * Start monitoring this performance counter
  30888. */
  30889. beginMonitoring(): void;
  30890. /**
  30891. * Compute the time lapsed since the previous beginMonitoring() call.
  30892. * @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
  30893. */
  30894. endMonitoring(newFrame?: boolean): void;
  30895. private _fetchResult;
  30896. private _startMonitoringTime;
  30897. private _min;
  30898. private _max;
  30899. private _average;
  30900. private _current;
  30901. private _totalValueCount;
  30902. private _totalAccumulated;
  30903. private _lastSecAverage;
  30904. private _lastSecAccumulated;
  30905. private _lastSecTime;
  30906. private _lastSecValueCount;
  30907. }
  30908. /**
  30909. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  30910. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  30911. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  30912. * @param name The name of the class, case should be preserved
  30913. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  30914. */
  30915. export function className(name: string, module?: string): (target: Object) => void;
  30916. /**
  30917. * An implementation of a loop for asynchronous functions.
  30918. */
  30919. export class AsyncLoop {
  30920. /**
  30921. * Defines the number of iterations for the loop
  30922. */
  30923. iterations: number;
  30924. /**
  30925. * Defines the current index of the loop.
  30926. */
  30927. index: number;
  30928. private _done;
  30929. private _fn;
  30930. private _successCallback;
  30931. /**
  30932. * Constructor.
  30933. * @param iterations the number of iterations.
  30934. * @param func the function to run each iteration
  30935. * @param successCallback the callback that will be called upon succesful execution
  30936. * @param offset starting offset.
  30937. */
  30938. constructor(
  30939. /**
  30940. * Defines the number of iterations for the loop
  30941. */
  30942. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  30943. /**
  30944. * Execute the next iteration. Must be called after the last iteration was finished.
  30945. */
  30946. executeNext(): void;
  30947. /**
  30948. * Break the loop and run the success callback.
  30949. */
  30950. breakLoop(): void;
  30951. /**
  30952. * Create and run an async loop.
  30953. * @param iterations the number of iterations.
  30954. * @param fn the function to run each iteration
  30955. * @param successCallback the callback that will be called upon succesful execution
  30956. * @param offset starting offset.
  30957. * @returns the created async loop object
  30958. */
  30959. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  30960. /**
  30961. * A for-loop that will run a given number of iterations synchronous and the rest async.
  30962. * @param iterations total number of iterations
  30963. * @param syncedIterations number of synchronous iterations in each async iteration.
  30964. * @param fn the function to call each iteration.
  30965. * @param callback a success call back that will be called when iterating stops.
  30966. * @param breakFunction a break condition (optional)
  30967. * @param timeout timeout settings for the setTimeout function. default - 0.
  30968. * @returns the created async loop object
  30969. */
  30970. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  30971. }
  30972. }
  30973. declare module BABYLON {
  30974. /** @hidden */
  30975. export interface ICollisionCoordinator {
  30976. createCollider(): Collider;
  30977. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30978. init(scene: Scene): void;
  30979. }
  30980. /** @hidden */
  30981. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  30982. private _scene;
  30983. private _scaledPosition;
  30984. private _scaledVelocity;
  30985. private _finalPosition;
  30986. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  30987. createCollider(): Collider;
  30988. init(scene: Scene): void;
  30989. private _collideWithWorld;
  30990. }
  30991. }
  30992. declare module BABYLON {
  30993. /**
  30994. * Class used to manage all inputs for the scene.
  30995. */
  30996. export class InputManager {
  30997. /** The distance in pixel that you have to move to prevent some events */
  30998. static DragMovementThreshold: number;
  30999. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31000. static LongPressDelay: number;
  31001. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31002. static DoubleClickDelay: number;
  31003. /** If you need to check double click without raising a single click at first click, enable this flag */
  31004. static ExclusiveDoubleClickMode: boolean;
  31005. private _wheelEventName;
  31006. private _onPointerMove;
  31007. private _onPointerDown;
  31008. private _onPointerUp;
  31009. private _initClickEvent;
  31010. private _initActionManager;
  31011. private _delayedSimpleClick;
  31012. private _delayedSimpleClickTimeout;
  31013. private _previousDelayedSimpleClickTimeout;
  31014. private _meshPickProceed;
  31015. private _previousButtonPressed;
  31016. private _currentPickResult;
  31017. private _previousPickResult;
  31018. private _totalPointersPressed;
  31019. private _doubleClickOccured;
  31020. private _pointerOverMesh;
  31021. private _pickedDownMesh;
  31022. private _pickedUpMesh;
  31023. private _pointerX;
  31024. private _pointerY;
  31025. private _unTranslatedPointerX;
  31026. private _unTranslatedPointerY;
  31027. private _startingPointerPosition;
  31028. private _previousStartingPointerPosition;
  31029. private _startingPointerTime;
  31030. private _previousStartingPointerTime;
  31031. private _pointerCaptures;
  31032. private _onKeyDown;
  31033. private _onKeyUp;
  31034. private _onCanvasFocusObserver;
  31035. private _onCanvasBlurObserver;
  31036. private _scene;
  31037. /**
  31038. * Creates a new InputManager
  31039. * @param scene defines the hosting scene
  31040. */
  31041. constructor(scene: Scene);
  31042. /**
  31043. * Gets the mesh that is currently under the pointer
  31044. */
  31045. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31046. /**
  31047. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31048. */
  31049. readonly unTranslatedPointer: Vector2;
  31050. /**
  31051. * Gets or sets the current on-screen X position of the pointer
  31052. */
  31053. pointerX: number;
  31054. /**
  31055. * Gets or sets the current on-screen Y position of the pointer
  31056. */
  31057. pointerY: number;
  31058. private _updatePointerPosition;
  31059. private _processPointerMove;
  31060. private _setRayOnPointerInfo;
  31061. private _checkPrePointerObservable;
  31062. /**
  31063. * Use this method to simulate a pointer move on a mesh
  31064. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31065. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31066. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31067. */
  31068. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31069. /**
  31070. * Use this method to simulate a pointer down on a mesh
  31071. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31072. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31073. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31074. */
  31075. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31076. private _processPointerDown;
  31077. /** @hidden */ private _isPointerSwiping(): boolean;
  31078. /**
  31079. * Use this method to simulate a pointer up on a mesh
  31080. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31081. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31082. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31083. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31084. */
  31085. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31086. private _processPointerUp;
  31087. /**
  31088. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31089. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31090. * @returns true if the pointer was captured
  31091. */
  31092. isPointerCaptured(pointerId?: number): boolean;
  31093. /**
  31094. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31095. * @param attachUp defines if you want to attach events to pointerup
  31096. * @param attachDown defines if you want to attach events to pointerdown
  31097. * @param attachMove defines if you want to attach events to pointermove
  31098. */
  31099. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31100. /**
  31101. * Detaches all event handlers
  31102. */
  31103. detachControl(): void;
  31104. /**
  31105. * Force the value of meshUnderPointer
  31106. * @param mesh defines the mesh to use
  31107. */
  31108. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31109. /**
  31110. * Gets the mesh under the pointer
  31111. * @returns a Mesh or null if no mesh is under the pointer
  31112. */
  31113. getPointerOverMesh(): Nullable<AbstractMesh>;
  31114. }
  31115. }
  31116. declare module BABYLON {
  31117. /**
  31118. * This class defines the direct association between an animation and a target
  31119. */
  31120. export class TargetedAnimation {
  31121. /**
  31122. * Animation to perform
  31123. */
  31124. animation: Animation;
  31125. /**
  31126. * Target to animate
  31127. */
  31128. target: any;
  31129. /**
  31130. * Serialize the object
  31131. * @returns the JSON object representing the current entity
  31132. */
  31133. serialize(): any;
  31134. }
  31135. /**
  31136. * Use this class to create coordinated animations on multiple targets
  31137. */
  31138. export class AnimationGroup implements IDisposable {
  31139. /** The name of the animation group */
  31140. name: string;
  31141. private _scene;
  31142. private _targetedAnimations;
  31143. private _animatables;
  31144. private _from;
  31145. private _to;
  31146. private _isStarted;
  31147. private _isPaused;
  31148. private _speedRatio;
  31149. private _loopAnimation;
  31150. /**
  31151. * Gets or sets the unique id of the node
  31152. */
  31153. uniqueId: number;
  31154. /**
  31155. * This observable will notify when one animation have ended
  31156. */
  31157. onAnimationEndObservable: Observable<TargetedAnimation>;
  31158. /**
  31159. * Observer raised when one animation loops
  31160. */
  31161. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31162. /**
  31163. * This observable will notify when all animations have ended.
  31164. */
  31165. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31166. /**
  31167. * This observable will notify when all animations have paused.
  31168. */
  31169. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31170. /**
  31171. * This observable will notify when all animations are playing.
  31172. */
  31173. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31174. /**
  31175. * Gets the first frame
  31176. */
  31177. readonly from: number;
  31178. /**
  31179. * Gets the last frame
  31180. */
  31181. readonly to: number;
  31182. /**
  31183. * Define if the animations are started
  31184. */
  31185. readonly isStarted: boolean;
  31186. /**
  31187. * Gets a value indicating that the current group is playing
  31188. */
  31189. readonly isPlaying: boolean;
  31190. /**
  31191. * Gets or sets the speed ratio to use for all animations
  31192. */
  31193. /**
  31194. * Gets or sets the speed ratio to use for all animations
  31195. */
  31196. speedRatio: number;
  31197. /**
  31198. * Gets or sets if all animations should loop or not
  31199. */
  31200. loopAnimation: boolean;
  31201. /**
  31202. * Gets the targeted animations for this animation group
  31203. */
  31204. readonly targetedAnimations: Array<TargetedAnimation>;
  31205. /**
  31206. * returning the list of animatables controlled by this animation group.
  31207. */
  31208. readonly animatables: Array<Animatable>;
  31209. /**
  31210. * Instantiates a new Animation Group.
  31211. * This helps managing several animations at once.
  31212. * @see http://doc.babylonjs.com/how_to/group
  31213. * @param name Defines the name of the group
  31214. * @param scene Defines the scene the group belongs to
  31215. */
  31216. constructor(
  31217. /** The name of the animation group */
  31218. name: string, scene?: Nullable<Scene>);
  31219. /**
  31220. * Add an animation (with its target) in the group
  31221. * @param animation defines the animation we want to add
  31222. * @param target defines the target of the animation
  31223. * @returns the TargetedAnimation object
  31224. */
  31225. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31226. /**
  31227. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31228. * It can add constant keys at begin or end
  31229. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31230. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31231. * @returns the animation group
  31232. */
  31233. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31234. /**
  31235. * Start all animations on given targets
  31236. * @param loop defines if animations must loop
  31237. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31238. * @param from defines the from key (optional)
  31239. * @param to defines the to key (optional)
  31240. * @returns the current animation group
  31241. */
  31242. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31243. /**
  31244. * Pause all animations
  31245. * @returns the animation group
  31246. */
  31247. pause(): AnimationGroup;
  31248. /**
  31249. * Play all animations to initial state
  31250. * This function will start() the animations if they were not started or will restart() them if they were paused
  31251. * @param loop defines if animations must loop
  31252. * @returns the animation group
  31253. */
  31254. play(loop?: boolean): AnimationGroup;
  31255. /**
  31256. * Reset all animations to initial state
  31257. * @returns the animation group
  31258. */
  31259. reset(): AnimationGroup;
  31260. /**
  31261. * Restart animations from key 0
  31262. * @returns the animation group
  31263. */
  31264. restart(): AnimationGroup;
  31265. /**
  31266. * Stop all animations
  31267. * @returns the animation group
  31268. */
  31269. stop(): AnimationGroup;
  31270. /**
  31271. * Set animation weight for all animatables
  31272. * @param weight defines the weight to use
  31273. * @return the animationGroup
  31274. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31275. */
  31276. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31277. /**
  31278. * Synchronize and normalize all animatables with a source animatable
  31279. * @param root defines the root animatable to synchronize with
  31280. * @return the animationGroup
  31281. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31282. */
  31283. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31284. /**
  31285. * Goes to a specific frame in this animation group
  31286. * @param frame the frame number to go to
  31287. * @return the animationGroup
  31288. */
  31289. goToFrame(frame: number): AnimationGroup;
  31290. /**
  31291. * Dispose all associated resources
  31292. */
  31293. dispose(): void;
  31294. private _checkAnimationGroupEnded;
  31295. /**
  31296. * Clone the current animation group and returns a copy
  31297. * @param newName defines the name of the new group
  31298. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31299. * @returns the new aniamtion group
  31300. */
  31301. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31302. /**
  31303. * Serializes the animationGroup to an object
  31304. * @returns Serialized object
  31305. */
  31306. serialize(): any;
  31307. /**
  31308. * Returns a new AnimationGroup object parsed from the source provided.
  31309. * @param parsedAnimationGroup defines the source
  31310. * @param scene defines the scene that will receive the animationGroup
  31311. * @returns a new AnimationGroup
  31312. */
  31313. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31314. /**
  31315. * Returns the string "AnimationGroup"
  31316. * @returns "AnimationGroup"
  31317. */
  31318. getClassName(): string;
  31319. /**
  31320. * Creates a detailled string about the object
  31321. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31322. * @returns a string representing the object
  31323. */
  31324. toString(fullDetails?: boolean): string;
  31325. }
  31326. }
  31327. declare module BABYLON {
  31328. /**
  31329. * Define an interface for all classes that will hold resources
  31330. */
  31331. export interface IDisposable {
  31332. /**
  31333. * Releases all held resources
  31334. */
  31335. dispose(): void;
  31336. }
  31337. /** Interface defining initialization parameters for Scene class */
  31338. export interface SceneOptions {
  31339. /**
  31340. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  31341. * It will improve performance when the number of geometries becomes important.
  31342. */
  31343. useGeometryUniqueIdsMap?: boolean;
  31344. /**
  31345. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  31346. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31347. */
  31348. useMaterialMeshMap?: boolean;
  31349. /**
  31350. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  31351. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  31352. */
  31353. useClonedMeshhMap?: boolean;
  31354. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  31355. virtual?: boolean;
  31356. }
  31357. /**
  31358. * Represents a scene to be rendered by the engine.
  31359. * @see http://doc.babylonjs.com/features/scene
  31360. */
  31361. export class Scene extends AbstractScene implements IAnimatable {
  31362. private static _uniqueIdCounter;
  31363. /** The fog is deactivated */
  31364. static readonly FOGMODE_NONE: number;
  31365. /** The fog density is following an exponential function */
  31366. static readonly FOGMODE_EXP: number;
  31367. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  31368. static readonly FOGMODE_EXP2: number;
  31369. /** The fog density is following a linear function. */
  31370. static readonly FOGMODE_LINEAR: number;
  31371. /**
  31372. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  31373. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31374. */
  31375. static MinDeltaTime: number;
  31376. /**
  31377. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  31378. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31379. */
  31380. static MaxDeltaTime: number;
  31381. /**
  31382. * Factory used to create the default material.
  31383. * @param name The name of the material to create
  31384. * @param scene The scene to create the material for
  31385. * @returns The default material
  31386. */
  31387. static DefaultMaterialFactory(scene: Scene): Material;
  31388. /**
  31389. * Factory used to create the a collision coordinator.
  31390. * @returns The collision coordinator
  31391. */
  31392. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  31393. /** @hidden */ private _inputManager: InputManager;
  31394. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  31395. cameraToUseForPointers: Nullable<Camera>;
  31396. /** @hidden */ protected readonly _isScene: boolean;
  31397. /**
  31398. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  31399. */
  31400. autoClear: boolean;
  31401. /**
  31402. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  31403. */
  31404. autoClearDepthAndStencil: boolean;
  31405. /**
  31406. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  31407. */
  31408. clearColor: Color4;
  31409. /**
  31410. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  31411. */
  31412. ambientColor: Color3;
  31413. /**
  31414. * This is use to store the default BRDF lookup for PBR materials in your scene.
  31415. * It should only be one of the following (if not the default embedded one):
  31416. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  31417. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  31418. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  31419. * The material properties need to be setup according to the type of texture in use.
  31420. */
  31421. environmentBRDFTexture: BaseTexture;
  31422. /** @hidden */
  31423. protected _environmentTexture: Nullable<BaseTexture>;
  31424. /**
  31425. * Texture used in all pbr material as the reflection texture.
  31426. * As in the majority of the scene they are the same (exception for multi room and so on),
  31427. * this is easier to reference from here than from all the materials.
  31428. */
  31429. /**
  31430. * Texture used in all pbr material as the reflection texture.
  31431. * As in the majority of the scene they are the same (exception for multi room and so on),
  31432. * this is easier to set here than in all the materials.
  31433. */
  31434. environmentTexture: Nullable<BaseTexture>;
  31435. /** @hidden */
  31436. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31437. /**
  31438. * Default image processing configuration used either in the rendering
  31439. * Forward main pass or through the imageProcessingPostProcess if present.
  31440. * As in the majority of the scene they are the same (exception for multi camera),
  31441. * this is easier to reference from here than from all the materials and post process.
  31442. *
  31443. * No setter as we it is a shared configuration, you can set the values instead.
  31444. */
  31445. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  31446. private _forceWireframe;
  31447. /**
  31448. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  31449. */
  31450. forceWireframe: boolean;
  31451. private _forcePointsCloud;
  31452. /**
  31453. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  31454. */
  31455. forcePointsCloud: boolean;
  31456. /**
  31457. * Gets or sets the active clipplane 1
  31458. */
  31459. clipPlane: Nullable<Plane>;
  31460. /**
  31461. * Gets or sets the active clipplane 2
  31462. */
  31463. clipPlane2: Nullable<Plane>;
  31464. /**
  31465. * Gets or sets the active clipplane 3
  31466. */
  31467. clipPlane3: Nullable<Plane>;
  31468. /**
  31469. * Gets or sets the active clipplane 4
  31470. */
  31471. clipPlane4: Nullable<Plane>;
  31472. /**
  31473. * Gets or sets a boolean indicating if animations are enabled
  31474. */
  31475. animationsEnabled: boolean;
  31476. private _animationPropertiesOverride;
  31477. /**
  31478. * Gets or sets the animation properties override
  31479. */
  31480. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  31481. /**
  31482. * Gets or sets a boolean indicating if a constant deltatime has to be used
  31483. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  31484. */
  31485. useConstantAnimationDeltaTime: boolean;
  31486. /**
  31487. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  31488. * Please note that it requires to run a ray cast through the scene on every frame
  31489. */
  31490. constantlyUpdateMeshUnderPointer: boolean;
  31491. /**
  31492. * Defines the HTML cursor to use when hovering over interactive elements
  31493. */
  31494. hoverCursor: string;
  31495. /**
  31496. * Defines the HTML default cursor to use (empty by default)
  31497. */
  31498. defaultCursor: string;
  31499. /**
  31500. * This is used to call preventDefault() on pointer down
  31501. * in order to block unwanted artifacts like system double clicks
  31502. */
  31503. preventDefaultOnPointerDown: boolean;
  31504. /**
  31505. * This is used to call preventDefault() on pointer up
  31506. * in order to block unwanted artifacts like system double clicks
  31507. */
  31508. preventDefaultOnPointerUp: boolean;
  31509. /**
  31510. * Gets or sets user defined metadata
  31511. */
  31512. metadata: any;
  31513. /**
  31514. * For internal use only. Please do not use.
  31515. */
  31516. reservedDataStore: any;
  31517. /**
  31518. * Gets the name of the plugin used to load this scene (null by default)
  31519. */
  31520. loadingPluginName: string;
  31521. /**
  31522. * Use this array to add regular expressions used to disable offline support for specific urls
  31523. */
  31524. disableOfflineSupportExceptionRules: RegExp[];
  31525. /**
  31526. * An event triggered when the scene is disposed.
  31527. */
  31528. onDisposeObservable: Observable<Scene>;
  31529. private _onDisposeObserver;
  31530. /** Sets a function to be executed when this scene is disposed. */
  31531. onDispose: () => void;
  31532. /**
  31533. * An event triggered before rendering the scene (right after animations and physics)
  31534. */
  31535. onBeforeRenderObservable: Observable<Scene>;
  31536. private _onBeforeRenderObserver;
  31537. /** Sets a function to be executed before rendering this scene */
  31538. beforeRender: Nullable<() => void>;
  31539. /**
  31540. * An event triggered after rendering the scene
  31541. */
  31542. onAfterRenderObservable: Observable<Scene>;
  31543. private _onAfterRenderObserver;
  31544. /** Sets a function to be executed after rendering this scene */
  31545. afterRender: Nullable<() => void>;
  31546. /**
  31547. * An event triggered before animating the scene
  31548. */
  31549. onBeforeAnimationsObservable: Observable<Scene>;
  31550. /**
  31551. * An event triggered after animations processing
  31552. */
  31553. onAfterAnimationsObservable: Observable<Scene>;
  31554. /**
  31555. * An event triggered before draw calls are ready to be sent
  31556. */
  31557. onBeforeDrawPhaseObservable: Observable<Scene>;
  31558. /**
  31559. * An event triggered after draw calls have been sent
  31560. */
  31561. onAfterDrawPhaseObservable: Observable<Scene>;
  31562. /**
  31563. * An event triggered when the scene is ready
  31564. */
  31565. onReadyObservable: Observable<Scene>;
  31566. /**
  31567. * An event triggered before rendering a camera
  31568. */
  31569. onBeforeCameraRenderObservable: Observable<Camera>;
  31570. private _onBeforeCameraRenderObserver;
  31571. /** Sets a function to be executed before rendering a camera*/
  31572. beforeCameraRender: () => void;
  31573. /**
  31574. * An event triggered after rendering a camera
  31575. */
  31576. onAfterCameraRenderObservable: Observable<Camera>;
  31577. private _onAfterCameraRenderObserver;
  31578. /** Sets a function to be executed after rendering a camera*/
  31579. afterCameraRender: () => void;
  31580. /**
  31581. * An event triggered when active meshes evaluation is about to start
  31582. */
  31583. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  31584. /**
  31585. * An event triggered when active meshes evaluation is done
  31586. */
  31587. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  31588. /**
  31589. * An event triggered when particles rendering is about to start
  31590. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31591. */
  31592. onBeforeParticlesRenderingObservable: Observable<Scene>;
  31593. /**
  31594. * An event triggered when particles rendering is done
  31595. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  31596. */
  31597. onAfterParticlesRenderingObservable: Observable<Scene>;
  31598. /**
  31599. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  31600. */
  31601. onDataLoadedObservable: Observable<Scene>;
  31602. /**
  31603. * An event triggered when a camera is created
  31604. */
  31605. onNewCameraAddedObservable: Observable<Camera>;
  31606. /**
  31607. * An event triggered when a camera is removed
  31608. */
  31609. onCameraRemovedObservable: Observable<Camera>;
  31610. /**
  31611. * An event triggered when a light is created
  31612. */
  31613. onNewLightAddedObservable: Observable<Light>;
  31614. /**
  31615. * An event triggered when a light is removed
  31616. */
  31617. onLightRemovedObservable: Observable<Light>;
  31618. /**
  31619. * An event triggered when a geometry is created
  31620. */
  31621. onNewGeometryAddedObservable: Observable<Geometry>;
  31622. /**
  31623. * An event triggered when a geometry is removed
  31624. */
  31625. onGeometryRemovedObservable: Observable<Geometry>;
  31626. /**
  31627. * An event triggered when a transform node is created
  31628. */
  31629. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  31630. /**
  31631. * An event triggered when a transform node is removed
  31632. */
  31633. onTransformNodeRemovedObservable: Observable<TransformNode>;
  31634. /**
  31635. * An event triggered when a mesh is created
  31636. */
  31637. onNewMeshAddedObservable: Observable<AbstractMesh>;
  31638. /**
  31639. * An event triggered when a mesh is removed
  31640. */
  31641. onMeshRemovedObservable: Observable<AbstractMesh>;
  31642. /**
  31643. * An event triggered when a skeleton is created
  31644. */
  31645. onNewSkeletonAddedObservable: Observable<Skeleton>;
  31646. /**
  31647. * An event triggered when a skeleton is removed
  31648. */
  31649. onSkeletonRemovedObservable: Observable<Skeleton>;
  31650. /**
  31651. * An event triggered when a material is created
  31652. */
  31653. onNewMaterialAddedObservable: Observable<Material>;
  31654. /**
  31655. * An event triggered when a material is removed
  31656. */
  31657. onMaterialRemovedObservable: Observable<Material>;
  31658. /**
  31659. * An event triggered when a texture is created
  31660. */
  31661. onNewTextureAddedObservable: Observable<BaseTexture>;
  31662. /**
  31663. * An event triggered when a texture is removed
  31664. */
  31665. onTextureRemovedObservable: Observable<BaseTexture>;
  31666. /**
  31667. * An event triggered when render targets are about to be rendered
  31668. * Can happen multiple times per frame.
  31669. */
  31670. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  31671. /**
  31672. * An event triggered when render targets were rendered.
  31673. * Can happen multiple times per frame.
  31674. */
  31675. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  31676. /**
  31677. * An event triggered before calculating deterministic simulation step
  31678. */
  31679. onBeforeStepObservable: Observable<Scene>;
  31680. /**
  31681. * An event triggered after calculating deterministic simulation step
  31682. */
  31683. onAfterStepObservable: Observable<Scene>;
  31684. /**
  31685. * An event triggered when the activeCamera property is updated
  31686. */
  31687. onActiveCameraChanged: Observable<Scene>;
  31688. /**
  31689. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  31690. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31691. * 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)
  31692. */
  31693. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31694. /**
  31695. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  31696. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  31697. * 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)
  31698. */
  31699. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  31700. /**
  31701. * This Observable will when a mesh has been imported into the scene.
  31702. */
  31703. onMeshImportedObservable: Observable<AbstractMesh>;
  31704. /**
  31705. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  31706. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  31707. */
  31708. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  31709. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  31710. /**
  31711. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  31712. */
  31713. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  31714. /**
  31715. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  31716. */
  31717. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  31718. /**
  31719. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  31720. */
  31721. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  31722. /** Callback called when a pointer move is detected */
  31723. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31724. /** Callback called when a pointer down is detected */
  31725. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  31726. /** Callback called when a pointer up is detected */
  31727. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  31728. /** Callback called when a pointer pick is detected */
  31729. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  31730. /**
  31731. * 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).
  31732. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  31733. */
  31734. onPrePointerObservable: Observable<PointerInfoPre>;
  31735. /**
  31736. * Observable event triggered each time an input event is received from the rendering canvas
  31737. */
  31738. onPointerObservable: Observable<PointerInfo>;
  31739. /**
  31740. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  31741. */
  31742. readonly unTranslatedPointer: Vector2;
  31743. /**
  31744. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  31745. */
  31746. static DragMovementThreshold: number;
  31747. /**
  31748. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  31749. */
  31750. static LongPressDelay: number;
  31751. /**
  31752. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  31753. */
  31754. static DoubleClickDelay: number;
  31755. /** If you need to check double click without raising a single click at first click, enable this flag */
  31756. static ExclusiveDoubleClickMode: boolean;
  31757. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  31758. /**
  31759. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  31760. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  31761. */
  31762. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  31763. /**
  31764. * Observable event triggered each time an keyboard event is received from the hosting window
  31765. */
  31766. onKeyboardObservable: Observable<KeyboardInfo>;
  31767. private _useRightHandedSystem;
  31768. /**
  31769. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  31770. */
  31771. useRightHandedSystem: boolean;
  31772. private _timeAccumulator;
  31773. private _currentStepId;
  31774. private _currentInternalStep;
  31775. /**
  31776. * Sets the step Id used by deterministic lock step
  31777. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31778. * @param newStepId defines the step Id
  31779. */
  31780. setStepId(newStepId: number): void;
  31781. /**
  31782. * Gets the step Id used by deterministic lock step
  31783. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31784. * @returns the step Id
  31785. */
  31786. getStepId(): number;
  31787. /**
  31788. * Gets the internal step used by deterministic lock step
  31789. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31790. * @returns the internal step
  31791. */
  31792. getInternalStep(): number;
  31793. private _fogEnabled;
  31794. /**
  31795. * Gets or sets a boolean indicating if fog is enabled on this scene
  31796. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31797. * (Default is true)
  31798. */
  31799. fogEnabled: boolean;
  31800. private _fogMode;
  31801. /**
  31802. * Gets or sets the fog mode to use
  31803. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31804. * | mode | value |
  31805. * | --- | --- |
  31806. * | FOGMODE_NONE | 0 |
  31807. * | FOGMODE_EXP | 1 |
  31808. * | FOGMODE_EXP2 | 2 |
  31809. * | FOGMODE_LINEAR | 3 |
  31810. */
  31811. fogMode: number;
  31812. /**
  31813. * Gets or sets the fog color to use
  31814. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31815. * (Default is Color3(0.2, 0.2, 0.3))
  31816. */
  31817. fogColor: Color3;
  31818. /**
  31819. * Gets or sets the fog density to use
  31820. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31821. * (Default is 0.1)
  31822. */
  31823. fogDensity: number;
  31824. /**
  31825. * Gets or sets the fog start distance to use
  31826. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31827. * (Default is 0)
  31828. */
  31829. fogStart: number;
  31830. /**
  31831. * Gets or sets the fog end distance to use
  31832. * @see http://doc.babylonjs.com/babylon101/environment#fog
  31833. * (Default is 1000)
  31834. */
  31835. fogEnd: number;
  31836. private _shadowsEnabled;
  31837. /**
  31838. * Gets or sets a boolean indicating if shadows are enabled on this scene
  31839. */
  31840. shadowsEnabled: boolean;
  31841. private _lightsEnabled;
  31842. /**
  31843. * Gets or sets a boolean indicating if lights are enabled on this scene
  31844. */
  31845. lightsEnabled: boolean;
  31846. /** All of the active cameras added to this scene. */
  31847. activeCameras: Camera[];
  31848. /** @hidden */ private _activeCamera: Nullable<Camera>;
  31849. /** Gets or sets the current active camera */
  31850. activeCamera: Nullable<Camera>;
  31851. private _defaultMaterial;
  31852. /** The default material used on meshes when no material is affected */
  31853. /** The default material used on meshes when no material is affected */
  31854. defaultMaterial: Material;
  31855. private _texturesEnabled;
  31856. /**
  31857. * Gets or sets a boolean indicating if textures are enabled on this scene
  31858. */
  31859. texturesEnabled: boolean;
  31860. /**
  31861. * Gets or sets a boolean indicating if particles are enabled on this scene
  31862. */
  31863. particlesEnabled: boolean;
  31864. /**
  31865. * Gets or sets a boolean indicating if sprites are enabled on this scene
  31866. */
  31867. spritesEnabled: boolean;
  31868. private _skeletonsEnabled;
  31869. /**
  31870. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  31871. */
  31872. skeletonsEnabled: boolean;
  31873. /**
  31874. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  31875. */
  31876. lensFlaresEnabled: boolean;
  31877. /**
  31878. * Gets or sets a boolean indicating if collisions are enabled on this scene
  31879. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31880. */
  31881. collisionsEnabled: boolean;
  31882. private _collisionCoordinator;
  31883. /** @hidden */
  31884. readonly collisionCoordinator: ICollisionCoordinator;
  31885. /**
  31886. * Defines the gravity applied to this scene (used only for collisions)
  31887. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  31888. */
  31889. gravity: Vector3;
  31890. /**
  31891. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  31892. */
  31893. postProcessesEnabled: boolean;
  31894. /**
  31895. * The list of postprocesses added to the scene
  31896. */
  31897. postProcesses: PostProcess[];
  31898. /**
  31899. * Gets the current postprocess manager
  31900. */
  31901. postProcessManager: PostProcessManager;
  31902. /**
  31903. * Gets or sets a boolean indicating if render targets are enabled on this scene
  31904. */
  31905. renderTargetsEnabled: boolean;
  31906. /**
  31907. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  31908. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  31909. */
  31910. dumpNextRenderTargets: boolean;
  31911. /**
  31912. * The list of user defined render targets added to the scene
  31913. */
  31914. customRenderTargets: RenderTargetTexture[];
  31915. /**
  31916. * Defines if texture loading must be delayed
  31917. * If true, textures will only be loaded when they need to be rendered
  31918. */
  31919. useDelayedTextureLoading: boolean;
  31920. /**
  31921. * Gets the list of meshes imported to the scene through SceneLoader
  31922. */
  31923. importedMeshesFiles: String[];
  31924. /**
  31925. * Gets or sets a boolean indicating if probes are enabled on this scene
  31926. */
  31927. probesEnabled: boolean;
  31928. /**
  31929. * Gets or sets the current offline provider to use to store scene data
  31930. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  31931. */
  31932. offlineProvider: IOfflineProvider;
  31933. /**
  31934. * Gets or sets the action manager associated with the scene
  31935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  31936. */
  31937. actionManager: AbstractActionManager;
  31938. private _meshesForIntersections;
  31939. /**
  31940. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  31941. */
  31942. proceduralTexturesEnabled: boolean;
  31943. private _engine;
  31944. private _totalVertices;
  31945. /** @hidden */ private _activeIndices: PerfCounter;
  31946. /** @hidden */ private _activeParticles: PerfCounter;
  31947. /** @hidden */ private _activeBones: PerfCounter;
  31948. private _animationRatio;
  31949. /** @hidden */ private _animationTimeLast: number;
  31950. /** @hidden */ private _animationTime: number;
  31951. /**
  31952. * Gets or sets a general scale for animation speed
  31953. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  31954. */
  31955. animationTimeScale: number;
  31956. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  31957. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  31958. /** @hidden */ private _cachedVisibility: Nullable<number>;
  31959. private _renderId;
  31960. private _frameId;
  31961. private _executeWhenReadyTimeoutId;
  31962. private _intermediateRendering;
  31963. private _viewUpdateFlag;
  31964. private _projectionUpdateFlag;
  31965. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  31966. private _activeRequests;
  31967. /** @hidden */ private _pendingData: any[];
  31968. private _isDisposed;
  31969. /**
  31970. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  31971. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  31972. */
  31973. dispatchAllSubMeshesOfActiveMeshes: boolean;
  31974. private _activeMeshes;
  31975. private _processedMaterials;
  31976. private _renderTargets;
  31977. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  31978. private _activeSkeletons;
  31979. private _softwareSkinnedMeshes;
  31980. private _renderingManager;
  31981. /** @hidden */ private _activeAnimatables: Animatable[];
  31982. private _transformMatrix;
  31983. private _sceneUbo;
  31984. /** @hidden */ private _viewMatrix: Matrix;
  31985. private _projectionMatrix;
  31986. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  31987. /** @hidden */ private _frustumPlanes: Plane[];
  31988. /**
  31989. * Gets the list of frustum planes (built from the active camera)
  31990. */
  31991. readonly frustumPlanes: Plane[];
  31992. /**
  31993. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  31994. * This is useful if there are more lights that the maximum simulteanous authorized
  31995. */
  31996. requireLightSorting: boolean;
  31997. /** @hidden */
  31998. readonly useMaterialMeshMap: boolean;
  31999. /** @hidden */
  32000. readonly useClonedMeshhMap: boolean;
  32001. private _externalData;
  32002. private _uid;
  32003. /**
  32004. * @hidden
  32005. * Backing store of defined scene components.
  32006. */ private _components: ISceneComponent[];
  32007. /**
  32008. * @hidden
  32009. * Backing store of defined scene components.
  32010. */ private _serializableComponents: ISceneSerializableComponent[];
  32011. /**
  32012. * List of components to register on the next registration step.
  32013. */
  32014. private _transientComponents;
  32015. /**
  32016. * Registers the transient components if needed.
  32017. */
  32018. private _registerTransientComponents;
  32019. /**
  32020. * @hidden
  32021. * Add a component to the scene.
  32022. * Note that the ccomponent could be registered on th next frame if this is called after
  32023. * the register component stage.
  32024. * @param component Defines the component to add to the scene
  32025. */ private _addComponent(component: ISceneComponent): void;
  32026. /**
  32027. * @hidden
  32028. * Gets a component from the scene.
  32029. * @param name defines the name of the component to retrieve
  32030. * @returns the component or null if not present
  32031. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32032. /**
  32033. * @hidden
  32034. * Defines the actions happening before camera updates.
  32035. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32036. /**
  32037. * @hidden
  32038. * Defines the actions happening before clear the canvas.
  32039. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32040. /**
  32041. * @hidden
  32042. * Defines the actions when collecting render targets for the frame.
  32043. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32044. /**
  32045. * @hidden
  32046. * Defines the actions happening for one camera in the frame.
  32047. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32048. /**
  32049. * @hidden
  32050. * Defines the actions happening during the per mesh ready checks.
  32051. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32052. /**
  32053. * @hidden
  32054. * Defines the actions happening before evaluate active mesh checks.
  32055. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32056. /**
  32057. * @hidden
  32058. * Defines the actions happening during the evaluate sub mesh checks.
  32059. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32060. /**
  32061. * @hidden
  32062. * Defines the actions happening during the active mesh stage.
  32063. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32064. /**
  32065. * @hidden
  32066. * Defines the actions happening during the per camera render target step.
  32067. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32068. /**
  32069. * @hidden
  32070. * Defines the actions happening just before the active camera is drawing.
  32071. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32072. /**
  32073. * @hidden
  32074. * Defines the actions happening just before a render target is drawing.
  32075. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32076. /**
  32077. * @hidden
  32078. * Defines the actions happening just before a rendering group is drawing.
  32079. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32080. /**
  32081. * @hidden
  32082. * Defines the actions happening just before a mesh is drawing.
  32083. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32084. /**
  32085. * @hidden
  32086. * Defines the actions happening just after a mesh has been drawn.
  32087. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32088. /**
  32089. * @hidden
  32090. * Defines the actions happening just after a rendering group has been drawn.
  32091. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32092. /**
  32093. * @hidden
  32094. * Defines the actions happening just after the active camera has been drawn.
  32095. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32096. /**
  32097. * @hidden
  32098. * Defines the actions happening just after a render target has been drawn.
  32099. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32100. /**
  32101. * @hidden
  32102. * Defines the actions happening just after rendering all cameras and computing intersections.
  32103. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32104. /**
  32105. * @hidden
  32106. * Defines the actions happening when a pointer move event happens.
  32107. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32108. /**
  32109. * @hidden
  32110. * Defines the actions happening when a pointer down event happens.
  32111. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32112. /**
  32113. * @hidden
  32114. * Defines the actions happening when a pointer up event happens.
  32115. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32116. /**
  32117. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32118. */
  32119. private geometriesByUniqueId;
  32120. /**
  32121. * Creates a new Scene
  32122. * @param engine defines the engine to use to render this scene
  32123. * @param options defines the scene options
  32124. */
  32125. constructor(engine: Engine, options?: SceneOptions);
  32126. /**
  32127. * Gets a string idenfifying the name of the class
  32128. * @returns "Scene" string
  32129. */
  32130. getClassName(): string;
  32131. private _defaultMeshCandidates;
  32132. /**
  32133. * @hidden
  32134. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32135. private _defaultSubMeshCandidates;
  32136. /**
  32137. * @hidden
  32138. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32139. /**
  32140. * Sets the default candidate providers for the scene.
  32141. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32142. * and getCollidingSubMeshCandidates to their default function
  32143. */
  32144. setDefaultCandidateProviders(): void;
  32145. /**
  32146. * Gets the mesh that is currently under the pointer
  32147. */
  32148. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32149. /**
  32150. * Gets or sets the current on-screen X position of the pointer
  32151. */
  32152. pointerX: number;
  32153. /**
  32154. * Gets or sets the current on-screen Y position of the pointer
  32155. */
  32156. pointerY: number;
  32157. /**
  32158. * Gets the cached material (ie. the latest rendered one)
  32159. * @returns the cached material
  32160. */
  32161. getCachedMaterial(): Nullable<Material>;
  32162. /**
  32163. * Gets the cached effect (ie. the latest rendered one)
  32164. * @returns the cached effect
  32165. */
  32166. getCachedEffect(): Nullable<Effect>;
  32167. /**
  32168. * Gets the cached visibility state (ie. the latest rendered one)
  32169. * @returns the cached visibility state
  32170. */
  32171. getCachedVisibility(): Nullable<number>;
  32172. /**
  32173. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32174. * @param material defines the current material
  32175. * @param effect defines the current effect
  32176. * @param visibility defines the current visibility state
  32177. * @returns true if one parameter is not cached
  32178. */
  32179. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32180. /**
  32181. * Gets the engine associated with the scene
  32182. * @returns an Engine
  32183. */
  32184. getEngine(): Engine;
  32185. /**
  32186. * Gets the total number of vertices rendered per frame
  32187. * @returns the total number of vertices rendered per frame
  32188. */
  32189. getTotalVertices(): number;
  32190. /**
  32191. * Gets the performance counter for total vertices
  32192. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32193. */
  32194. readonly totalVerticesPerfCounter: PerfCounter;
  32195. /**
  32196. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32197. * @returns the total number of active indices rendered per frame
  32198. */
  32199. getActiveIndices(): number;
  32200. /**
  32201. * Gets the performance counter for active indices
  32202. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32203. */
  32204. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32205. /**
  32206. * Gets the total number of active particles rendered per frame
  32207. * @returns the total number of active particles rendered per frame
  32208. */
  32209. getActiveParticles(): number;
  32210. /**
  32211. * Gets the performance counter for active particles
  32212. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32213. */
  32214. readonly activeParticlesPerfCounter: PerfCounter;
  32215. /**
  32216. * Gets the total number of active bones rendered per frame
  32217. * @returns the total number of active bones rendered per frame
  32218. */
  32219. getActiveBones(): number;
  32220. /**
  32221. * Gets the performance counter for active bones
  32222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32223. */
  32224. readonly activeBonesPerfCounter: PerfCounter;
  32225. /**
  32226. * Gets the array of active meshes
  32227. * @returns an array of AbstractMesh
  32228. */
  32229. getActiveMeshes(): SmartArray<AbstractMesh>;
  32230. /**
  32231. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32232. * @returns a number
  32233. */
  32234. getAnimationRatio(): number;
  32235. /**
  32236. * Gets an unique Id for the current render phase
  32237. * @returns a number
  32238. */
  32239. getRenderId(): number;
  32240. /**
  32241. * Gets an unique Id for the current frame
  32242. * @returns a number
  32243. */
  32244. getFrameId(): number;
  32245. /** Call this function if you want to manually increment the render Id*/
  32246. incrementRenderId(): void;
  32247. private _createUbo;
  32248. /**
  32249. * Use this method to simulate a pointer move on a mesh
  32250. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32251. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32252. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32253. * @returns the current scene
  32254. */
  32255. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32256. /**
  32257. * Use this method to simulate a pointer down on a mesh
  32258. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32259. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32260. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32261. * @returns the current scene
  32262. */
  32263. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32264. /**
  32265. * Use this method to simulate a pointer up on a mesh
  32266. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32267. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32268. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32269. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32270. * @returns the current scene
  32271. */
  32272. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32273. /**
  32274. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32275. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32276. * @returns true if the pointer was captured
  32277. */
  32278. isPointerCaptured(pointerId?: number): boolean;
  32279. /**
  32280. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32281. * @param attachUp defines if you want to attach events to pointerup
  32282. * @param attachDown defines if you want to attach events to pointerdown
  32283. * @param attachMove defines if you want to attach events to pointermove
  32284. */
  32285. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32286. /** Detaches all event handlers*/
  32287. detachControl(): void;
  32288. /**
  32289. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32290. * Delay loaded resources are not taking in account
  32291. * @return true if all required resources are ready
  32292. */
  32293. isReady(): boolean;
  32294. /** Resets all cached information relative to material (including effect and visibility) */
  32295. resetCachedMaterial(): void;
  32296. /**
  32297. * Registers a function to be called before every frame render
  32298. * @param func defines the function to register
  32299. */
  32300. registerBeforeRender(func: () => void): void;
  32301. /**
  32302. * Unregisters a function called before every frame render
  32303. * @param func defines the function to unregister
  32304. */
  32305. unregisterBeforeRender(func: () => void): void;
  32306. /**
  32307. * Registers a function to be called after every frame render
  32308. * @param func defines the function to register
  32309. */
  32310. registerAfterRender(func: () => void): void;
  32311. /**
  32312. * Unregisters a function called after every frame render
  32313. * @param func defines the function to unregister
  32314. */
  32315. unregisterAfterRender(func: () => void): void;
  32316. private _executeOnceBeforeRender;
  32317. /**
  32318. * The provided function will run before render once and will be disposed afterwards.
  32319. * A timeout delay can be provided so that the function will be executed in N ms.
  32320. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32321. * @param func The function to be executed.
  32322. * @param timeout optional delay in ms
  32323. */
  32324. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  32325. /** @hidden */ private _addPendingData(data: any): void;
  32326. /** @hidden */ private _removePendingData(data: any): void;
  32327. /**
  32328. * Returns the number of items waiting to be loaded
  32329. * @returns the number of items waiting to be loaded
  32330. */
  32331. getWaitingItemsCount(): number;
  32332. /**
  32333. * Returns a boolean indicating if the scene is still loading data
  32334. */
  32335. readonly isLoading: boolean;
  32336. /**
  32337. * Registers a function to be executed when the scene is ready
  32338. * @param {Function} func - the function to be executed
  32339. */
  32340. executeWhenReady(func: () => void): void;
  32341. /**
  32342. * Returns a promise that resolves when the scene is ready
  32343. * @returns A promise that resolves when the scene is ready
  32344. */
  32345. whenReadyAsync(): Promise<void>;
  32346. /** @hidden */ private _checkIsReady(): void;
  32347. /**
  32348. * Gets all animatable attached to the scene
  32349. */
  32350. readonly animatables: Animatable[];
  32351. /**
  32352. * Resets the last animation time frame.
  32353. * Useful to override when animations start running when loading a scene for the first time.
  32354. */
  32355. resetLastAnimationTimeFrame(): void;
  32356. /**
  32357. * Gets the current view matrix
  32358. * @returns a Matrix
  32359. */
  32360. getViewMatrix(): Matrix;
  32361. /**
  32362. * Gets the current projection matrix
  32363. * @returns a Matrix
  32364. */
  32365. getProjectionMatrix(): Matrix;
  32366. /**
  32367. * Gets the current transform matrix
  32368. * @returns a Matrix made of View * Projection
  32369. */
  32370. getTransformMatrix(): Matrix;
  32371. /**
  32372. * Sets the current transform matrix
  32373. * @param viewL defines the View matrix to use
  32374. * @param projectionL defines the Projection matrix to use
  32375. * @param viewR defines the right View matrix to use (if provided)
  32376. * @param projectionR defines the right Projection matrix to use (if provided)
  32377. */
  32378. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  32379. /**
  32380. * Gets the uniform buffer used to store scene data
  32381. * @returns a UniformBuffer
  32382. */
  32383. getSceneUniformBuffer(): UniformBuffer;
  32384. /**
  32385. * Gets an unique (relatively to the current scene) Id
  32386. * @returns an unique number for the scene
  32387. */
  32388. getUniqueId(): number;
  32389. /**
  32390. * Add a mesh to the list of scene's meshes
  32391. * @param newMesh defines the mesh to add
  32392. * @param recursive if all child meshes should also be added to the scene
  32393. */
  32394. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  32395. /**
  32396. * Remove a mesh for the list of scene's meshes
  32397. * @param toRemove defines the mesh to remove
  32398. * @param recursive if all child meshes should also be removed from the scene
  32399. * @returns the index where the mesh was in the mesh list
  32400. */
  32401. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  32402. /**
  32403. * Add a transform node to the list of scene's transform nodes
  32404. * @param newTransformNode defines the transform node to add
  32405. */
  32406. addTransformNode(newTransformNode: TransformNode): void;
  32407. /**
  32408. * Remove a transform node for the list of scene's transform nodes
  32409. * @param toRemove defines the transform node to remove
  32410. * @returns the index where the transform node was in the transform node list
  32411. */
  32412. removeTransformNode(toRemove: TransformNode): number;
  32413. /**
  32414. * Remove a skeleton for the list of scene's skeletons
  32415. * @param toRemove defines the skeleton to remove
  32416. * @returns the index where the skeleton was in the skeleton list
  32417. */
  32418. removeSkeleton(toRemove: Skeleton): number;
  32419. /**
  32420. * Remove a morph target for the list of scene's morph targets
  32421. * @param toRemove defines the morph target to remove
  32422. * @returns the index where the morph target was in the morph target list
  32423. */
  32424. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  32425. /**
  32426. * Remove a light for the list of scene's lights
  32427. * @param toRemove defines the light to remove
  32428. * @returns the index where the light was in the light list
  32429. */
  32430. removeLight(toRemove: Light): number;
  32431. /**
  32432. * Remove a camera for the list of scene's cameras
  32433. * @param toRemove defines the camera to remove
  32434. * @returns the index where the camera was in the camera list
  32435. */
  32436. removeCamera(toRemove: Camera): number;
  32437. /**
  32438. * Remove a particle system for the list of scene's particle systems
  32439. * @param toRemove defines the particle system to remove
  32440. * @returns the index where the particle system was in the particle system list
  32441. */
  32442. removeParticleSystem(toRemove: IParticleSystem): number;
  32443. /**
  32444. * Remove a animation for the list of scene's animations
  32445. * @param toRemove defines the animation to remove
  32446. * @returns the index where the animation was in the animation list
  32447. */
  32448. removeAnimation(toRemove: Animation): number;
  32449. /**
  32450. * Will stop the animation of the given target
  32451. * @param target - the target
  32452. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  32453. * @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)
  32454. */
  32455. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  32456. /**
  32457. * Removes the given animation group from this scene.
  32458. * @param toRemove The animation group to remove
  32459. * @returns The index of the removed animation group
  32460. */
  32461. removeAnimationGroup(toRemove: AnimationGroup): number;
  32462. /**
  32463. * Removes the given multi-material from this scene.
  32464. * @param toRemove The multi-material to remove
  32465. * @returns The index of the removed multi-material
  32466. */
  32467. removeMultiMaterial(toRemove: MultiMaterial): number;
  32468. /**
  32469. * Removes the given material from this scene.
  32470. * @param toRemove The material to remove
  32471. * @returns The index of the removed material
  32472. */
  32473. removeMaterial(toRemove: Material): number;
  32474. /**
  32475. * Removes the given action manager from this scene.
  32476. * @param toRemove The action manager to remove
  32477. * @returns The index of the removed action manager
  32478. */
  32479. removeActionManager(toRemove: AbstractActionManager): number;
  32480. /**
  32481. * Removes the given texture from this scene.
  32482. * @param toRemove The texture to remove
  32483. * @returns The index of the removed texture
  32484. */
  32485. removeTexture(toRemove: BaseTexture): number;
  32486. /**
  32487. * Adds the given light to this scene
  32488. * @param newLight The light to add
  32489. */
  32490. addLight(newLight: Light): void;
  32491. /**
  32492. * Sorts the list list based on light priorities
  32493. */
  32494. sortLightsByPriority(): void;
  32495. /**
  32496. * Adds the given camera to this scene
  32497. * @param newCamera The camera to add
  32498. */
  32499. addCamera(newCamera: Camera): void;
  32500. /**
  32501. * Adds the given skeleton to this scene
  32502. * @param newSkeleton The skeleton to add
  32503. */
  32504. addSkeleton(newSkeleton: Skeleton): void;
  32505. /**
  32506. * Adds the given particle system to this scene
  32507. * @param newParticleSystem The particle system to add
  32508. */
  32509. addParticleSystem(newParticleSystem: IParticleSystem): void;
  32510. /**
  32511. * Adds the given animation to this scene
  32512. * @param newAnimation The animation to add
  32513. */
  32514. addAnimation(newAnimation: Animation): void;
  32515. /**
  32516. * Adds the given animation group to this scene.
  32517. * @param newAnimationGroup The animation group to add
  32518. */
  32519. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  32520. /**
  32521. * Adds the given multi-material to this scene
  32522. * @param newMultiMaterial The multi-material to add
  32523. */
  32524. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  32525. /**
  32526. * Adds the given material to this scene
  32527. * @param newMaterial The material to add
  32528. */
  32529. addMaterial(newMaterial: Material): void;
  32530. /**
  32531. * Adds the given morph target to this scene
  32532. * @param newMorphTargetManager The morph target to add
  32533. */
  32534. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  32535. /**
  32536. * Adds the given geometry to this scene
  32537. * @param newGeometry The geometry to add
  32538. */
  32539. addGeometry(newGeometry: Geometry): void;
  32540. /**
  32541. * Adds the given action manager to this scene
  32542. * @param newActionManager The action manager to add
  32543. */
  32544. addActionManager(newActionManager: AbstractActionManager): void;
  32545. /**
  32546. * Adds the given texture to this scene.
  32547. * @param newTexture The texture to add
  32548. */
  32549. addTexture(newTexture: BaseTexture): void;
  32550. /**
  32551. * Switch active camera
  32552. * @param newCamera defines the new active camera
  32553. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  32554. */
  32555. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  32556. /**
  32557. * sets the active camera of the scene using its ID
  32558. * @param id defines the camera's ID
  32559. * @return the new active camera or null if none found.
  32560. */
  32561. setActiveCameraByID(id: string): Nullable<Camera>;
  32562. /**
  32563. * sets the active camera of the scene using its name
  32564. * @param name defines the camera's name
  32565. * @returns the new active camera or null if none found.
  32566. */
  32567. setActiveCameraByName(name: string): Nullable<Camera>;
  32568. /**
  32569. * get an animation group using its name
  32570. * @param name defines the material's name
  32571. * @return the animation group or null if none found.
  32572. */
  32573. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  32574. /**
  32575. * Get a material using its unique id
  32576. * @param uniqueId defines the material's unique id
  32577. * @return the material or null if none found.
  32578. */
  32579. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  32580. /**
  32581. * get a material using its id
  32582. * @param id defines the material's ID
  32583. * @return the material or null if none found.
  32584. */
  32585. getMaterialByID(id: string): Nullable<Material>;
  32586. /**
  32587. * Gets a material using its name
  32588. * @param name defines the material's name
  32589. * @return the material or null if none found.
  32590. */
  32591. getMaterialByName(name: string): Nullable<Material>;
  32592. /**
  32593. * Gets a camera using its id
  32594. * @param id defines the id to look for
  32595. * @returns the camera or null if not found
  32596. */
  32597. getCameraByID(id: string): Nullable<Camera>;
  32598. /**
  32599. * Gets a camera using its unique id
  32600. * @param uniqueId defines the unique id to look for
  32601. * @returns the camera or null if not found
  32602. */
  32603. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  32604. /**
  32605. * Gets a camera using its name
  32606. * @param name defines the camera's name
  32607. * @return the camera or null if none found.
  32608. */
  32609. getCameraByName(name: string): Nullable<Camera>;
  32610. /**
  32611. * Gets a bone using its id
  32612. * @param id defines the bone's id
  32613. * @return the bone or null if not found
  32614. */
  32615. getBoneByID(id: string): Nullable<Bone>;
  32616. /**
  32617. * Gets a bone using its id
  32618. * @param name defines the bone's name
  32619. * @return the bone or null if not found
  32620. */
  32621. getBoneByName(name: string): Nullable<Bone>;
  32622. /**
  32623. * Gets a light node using its name
  32624. * @param name defines the the light's name
  32625. * @return the light or null if none found.
  32626. */
  32627. getLightByName(name: string): Nullable<Light>;
  32628. /**
  32629. * Gets a light node using its id
  32630. * @param id defines the light's id
  32631. * @return the light or null if none found.
  32632. */
  32633. getLightByID(id: string): Nullable<Light>;
  32634. /**
  32635. * Gets a light node using its scene-generated unique ID
  32636. * @param uniqueId defines the light's unique id
  32637. * @return the light or null if none found.
  32638. */
  32639. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  32640. /**
  32641. * Gets a particle system by id
  32642. * @param id defines the particle system id
  32643. * @return the corresponding system or null if none found
  32644. */
  32645. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  32646. /**
  32647. * Gets a geometry using its ID
  32648. * @param id defines the geometry's id
  32649. * @return the geometry or null if none found.
  32650. */
  32651. getGeometryByID(id: string): Nullable<Geometry>;
  32652. private _getGeometryByUniqueID;
  32653. /**
  32654. * Add a new geometry to this scene
  32655. * @param geometry defines the geometry to be added to the scene.
  32656. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  32657. * @return a boolean defining if the geometry was added or not
  32658. */
  32659. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  32660. /**
  32661. * Removes an existing geometry
  32662. * @param geometry defines the geometry to be removed from the scene
  32663. * @return a boolean defining if the geometry was removed or not
  32664. */
  32665. removeGeometry(geometry: Geometry): boolean;
  32666. /**
  32667. * Gets the list of geometries attached to the scene
  32668. * @returns an array of Geometry
  32669. */
  32670. getGeometries(): Geometry[];
  32671. /**
  32672. * Gets the first added mesh found of a given ID
  32673. * @param id defines the id to search for
  32674. * @return the mesh found or null if not found at all
  32675. */
  32676. getMeshByID(id: string): Nullable<AbstractMesh>;
  32677. /**
  32678. * Gets a list of meshes using their id
  32679. * @param id defines the id to search for
  32680. * @returns a list of meshes
  32681. */
  32682. getMeshesByID(id: string): Array<AbstractMesh>;
  32683. /**
  32684. * Gets the first added transform node found of a given ID
  32685. * @param id defines the id to search for
  32686. * @return the found transform node or null if not found at all.
  32687. */
  32688. getTransformNodeByID(id: string): Nullable<TransformNode>;
  32689. /**
  32690. * Gets a transform node with its auto-generated unique id
  32691. * @param uniqueId efines the unique id to search for
  32692. * @return the found transform node or null if not found at all.
  32693. */
  32694. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  32695. /**
  32696. * Gets a list of transform nodes using their id
  32697. * @param id defines the id to search for
  32698. * @returns a list of transform nodes
  32699. */
  32700. getTransformNodesByID(id: string): Array<TransformNode>;
  32701. /**
  32702. * Gets a mesh with its auto-generated unique id
  32703. * @param uniqueId defines the unique id to search for
  32704. * @return the found mesh or null if not found at all.
  32705. */
  32706. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  32707. /**
  32708. * Gets a the last added mesh using a given id
  32709. * @param id defines the id to search for
  32710. * @return the found mesh or null if not found at all.
  32711. */
  32712. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  32713. /**
  32714. * Gets a the last added node (Mesh, Camera, Light) using a given id
  32715. * @param id defines the id to search for
  32716. * @return the found node or null if not found at all
  32717. */
  32718. getLastEntryByID(id: string): Nullable<Node>;
  32719. /**
  32720. * Gets a node (Mesh, Camera, Light) using a given id
  32721. * @param id defines the id to search for
  32722. * @return the found node or null if not found at all
  32723. */
  32724. getNodeByID(id: string): Nullable<Node>;
  32725. /**
  32726. * Gets a node (Mesh, Camera, Light) using a given name
  32727. * @param name defines the name to search for
  32728. * @return the found node or null if not found at all.
  32729. */
  32730. getNodeByName(name: string): Nullable<Node>;
  32731. /**
  32732. * Gets a mesh using a given name
  32733. * @param name defines the name to search for
  32734. * @return the found mesh or null if not found at all.
  32735. */
  32736. getMeshByName(name: string): Nullable<AbstractMesh>;
  32737. /**
  32738. * Gets a transform node using a given name
  32739. * @param name defines the name to search for
  32740. * @return the found transform node or null if not found at all.
  32741. */
  32742. getTransformNodeByName(name: string): Nullable<TransformNode>;
  32743. /**
  32744. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  32745. * @param id defines the id to search for
  32746. * @return the found skeleton or null if not found at all.
  32747. */
  32748. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  32749. /**
  32750. * Gets a skeleton using a given auto generated unique id
  32751. * @param uniqueId defines the unique id to search for
  32752. * @return the found skeleton or null if not found at all.
  32753. */
  32754. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  32755. /**
  32756. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  32757. * @param id defines the id to search for
  32758. * @return the found skeleton or null if not found at all.
  32759. */
  32760. getSkeletonById(id: string): Nullable<Skeleton>;
  32761. /**
  32762. * Gets a skeleton using a given name
  32763. * @param name defines the name to search for
  32764. * @return the found skeleton or null if not found at all.
  32765. */
  32766. getSkeletonByName(name: string): Nullable<Skeleton>;
  32767. /**
  32768. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  32769. * @param id defines the id to search for
  32770. * @return the found morph target manager or null if not found at all.
  32771. */
  32772. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  32773. /**
  32774. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  32775. * @param id defines the id to search for
  32776. * @return the found morph target or null if not found at all.
  32777. */
  32778. getMorphTargetById(id: string): Nullable<MorphTarget>;
  32779. /**
  32780. * Gets a boolean indicating if the given mesh is active
  32781. * @param mesh defines the mesh to look for
  32782. * @returns true if the mesh is in the active list
  32783. */
  32784. isActiveMesh(mesh: AbstractMesh): boolean;
  32785. /**
  32786. * Return a unique id as a string which can serve as an identifier for the scene
  32787. */
  32788. readonly uid: string;
  32789. /**
  32790. * Add an externaly attached data from its key.
  32791. * This method call will fail and return false, if such key already exists.
  32792. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32793. * @param key the unique key that identifies the data
  32794. * @param data the data object to associate to the key for this Engine instance
  32795. * @return true if no such key were already present and the data was added successfully, false otherwise
  32796. */
  32797. addExternalData<T>(key: string, data: T): boolean;
  32798. /**
  32799. * Get an externaly attached data from its key
  32800. * @param key the unique key that identifies the data
  32801. * @return the associated data, if present (can be null), or undefined if not present
  32802. */
  32803. getExternalData<T>(key: string): Nullable<T>;
  32804. /**
  32805. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32806. * @param key the unique key that identifies the data
  32807. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32808. * @return the associated data, can be null if the factory returned null.
  32809. */
  32810. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  32811. /**
  32812. * Remove an externaly attached data from the Engine instance
  32813. * @param key the unique key that identifies the data
  32814. * @return true if the data was successfully removed, false if it doesn't exist
  32815. */
  32816. removeExternalData(key: string): boolean;
  32817. private _evaluateSubMesh;
  32818. /**
  32819. * Clear the processed materials smart array preventing retention point in material dispose.
  32820. */
  32821. freeProcessedMaterials(): void;
  32822. private _preventFreeActiveMeshesAndRenderingGroups;
  32823. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  32824. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  32825. * when disposing several meshes in a row or a hierarchy of meshes.
  32826. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  32827. */
  32828. blockfreeActiveMeshesAndRenderingGroups: boolean;
  32829. /**
  32830. * Clear the active meshes smart array preventing retention point in mesh dispose.
  32831. */
  32832. freeActiveMeshes(): void;
  32833. /**
  32834. * Clear the info related to rendering groups preventing retention points during dispose.
  32835. */
  32836. freeRenderingGroups(): void;
  32837. /** @hidden */ private _isInIntermediateRendering(): boolean;
  32838. /**
  32839. * Lambda returning the list of potentially active meshes.
  32840. */
  32841. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  32842. /**
  32843. * Lambda returning the list of potentially active sub meshes.
  32844. */
  32845. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  32846. /**
  32847. * Lambda returning the list of potentially intersecting sub meshes.
  32848. */
  32849. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  32850. /**
  32851. * Lambda returning the list of potentially colliding sub meshes.
  32852. */
  32853. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  32854. private _activeMeshesFrozen;
  32855. /**
  32856. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  32857. * @returns the current scene
  32858. */
  32859. freezeActiveMeshes(): Scene;
  32860. /**
  32861. * Use this function to restart evaluating active meshes on every frame
  32862. * @returns the current scene
  32863. */
  32864. unfreezeActiveMeshes(): Scene;
  32865. private _evaluateActiveMeshes;
  32866. private _activeMesh;
  32867. /**
  32868. * Update the transform matrix to update from the current active camera
  32869. * @param force defines a boolean used to force the update even if cache is up to date
  32870. */
  32871. updateTransformMatrix(force?: boolean): void;
  32872. private _bindFrameBuffer;
  32873. /** @hidden */ private _allowPostProcessClearColor: boolean;
  32874. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  32875. private _processSubCameras;
  32876. private _checkIntersections;
  32877. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  32878. /**
  32879. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  32880. */
  32881. getDeterministicFrameTime: () => number;
  32882. /** @hidden */ private _animate(): void;
  32883. /** Execute all animations (for a frame) */
  32884. animate(): void;
  32885. /**
  32886. * Render the scene
  32887. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  32888. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  32889. */
  32890. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  32891. /**
  32892. * Freeze all materials
  32893. * A frozen material will not be updatable but should be faster to render
  32894. */
  32895. freezeMaterials(): void;
  32896. /**
  32897. * Unfreeze all materials
  32898. * A frozen material will not be updatable but should be faster to render
  32899. */
  32900. unfreezeMaterials(): void;
  32901. /**
  32902. * Releases all held ressources
  32903. */
  32904. dispose(): void;
  32905. /**
  32906. * Gets if the scene is already disposed
  32907. */
  32908. readonly isDisposed: boolean;
  32909. /**
  32910. * Call this function to reduce memory footprint of the scene.
  32911. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  32912. */
  32913. clearCachedVertexData(): void;
  32914. /**
  32915. * This function will remove the local cached buffer data from texture.
  32916. * It will save memory but will prevent the texture from being rebuilt
  32917. */
  32918. cleanCachedTextureBuffer(): void;
  32919. /**
  32920. * Get the world extend vectors with an optional filter
  32921. *
  32922. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  32923. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  32924. */
  32925. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  32926. min: Vector3;
  32927. max: Vector3;
  32928. };
  32929. /**
  32930. * Creates a ray that can be used to pick in the scene
  32931. * @param x defines the x coordinate of the origin (on-screen)
  32932. * @param y defines the y coordinate of the origin (on-screen)
  32933. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32934. * @param camera defines the camera to use for the picking
  32935. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32936. * @returns a Ray
  32937. */
  32938. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  32939. /**
  32940. * Creates a ray that can be used to pick in the scene
  32941. * @param x defines the x coordinate of the origin (on-screen)
  32942. * @param y defines the y coordinate of the origin (on-screen)
  32943. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  32944. * @param result defines the ray where to store the picking ray
  32945. * @param camera defines the camera to use for the picking
  32946. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  32947. * @returns the current scene
  32948. */
  32949. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  32950. /**
  32951. * Creates a ray that can be used to pick in the scene
  32952. * @param x defines the x coordinate of the origin (on-screen)
  32953. * @param y defines the y coordinate of the origin (on-screen)
  32954. * @param camera defines the camera to use for the picking
  32955. * @returns a Ray
  32956. */
  32957. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  32958. /**
  32959. * Creates a ray that can be used to pick in the scene
  32960. * @param x defines the x coordinate of the origin (on-screen)
  32961. * @param y defines the y coordinate of the origin (on-screen)
  32962. * @param result defines the ray where to store the picking ray
  32963. * @param camera defines the camera to use for the picking
  32964. * @returns the current scene
  32965. */
  32966. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  32967. /** Launch a ray to try to pick a mesh in the scene
  32968. * @param x position on screen
  32969. * @param y position on screen
  32970. * @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
  32971. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  32972. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32973. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32974. * @returns a PickingInfo
  32975. */
  32976. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  32977. /** Use the given ray to pick a mesh in the scene
  32978. * @param ray The ray to use to pick meshes
  32979. * @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
  32980. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  32981. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32982. * @returns a PickingInfo
  32983. */
  32984. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  32985. /**
  32986. * Launch a ray to try to pick a mesh in the scene
  32987. * @param x X position on screen
  32988. * @param y Y position on screen
  32989. * @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
  32990. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  32991. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32992. * @returns an array of PickingInfo
  32993. */
  32994. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  32995. /**
  32996. * Launch a ray to try to pick a mesh in the scene
  32997. * @param ray Ray to use
  32998. * @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
  32999. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33000. * @returns an array of PickingInfo
  33001. */
  33002. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33003. /**
  33004. * Force the value of meshUnderPointer
  33005. * @param mesh defines the mesh to use
  33006. */
  33007. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33008. /**
  33009. * Gets the mesh under the pointer
  33010. * @returns a Mesh or null if no mesh is under the pointer
  33011. */
  33012. getPointerOverMesh(): Nullable<AbstractMesh>;
  33013. /** @hidden */ private _rebuildGeometries(): void;
  33014. /** @hidden */ private _rebuildTextures(): void;
  33015. private _getByTags;
  33016. /**
  33017. * Get a list of meshes by tags
  33018. * @param tagsQuery defines the tags query to use
  33019. * @param forEach defines a predicate used to filter results
  33020. * @returns an array of Mesh
  33021. */
  33022. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33023. /**
  33024. * Get a list of cameras by tags
  33025. * @param tagsQuery defines the tags query to use
  33026. * @param forEach defines a predicate used to filter results
  33027. * @returns an array of Camera
  33028. */
  33029. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33030. /**
  33031. * Get a list of lights by tags
  33032. * @param tagsQuery defines the tags query to use
  33033. * @param forEach defines a predicate used to filter results
  33034. * @returns an array of Light
  33035. */
  33036. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33037. /**
  33038. * Get a list of materials by tags
  33039. * @param tagsQuery defines the tags query to use
  33040. * @param forEach defines a predicate used to filter results
  33041. * @returns an array of Material
  33042. */
  33043. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33044. /**
  33045. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33046. * This allowed control for front to back rendering or reversly depending of the special needs.
  33047. *
  33048. * @param renderingGroupId The rendering group id corresponding to its index
  33049. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33050. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33051. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33052. */
  33053. 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;
  33054. /**
  33055. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33056. *
  33057. * @param renderingGroupId The rendering group id corresponding to its index
  33058. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33059. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33060. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33061. */
  33062. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33063. /**
  33064. * Gets the current auto clear configuration for one rendering group of the rendering
  33065. * manager.
  33066. * @param index the rendering group index to get the information for
  33067. * @returns The auto clear setup for the requested rendering group
  33068. */
  33069. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33070. private _blockMaterialDirtyMechanism;
  33071. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33072. blockMaterialDirtyMechanism: boolean;
  33073. /**
  33074. * Will flag all materials as dirty to trigger new shader compilation
  33075. * @param flag defines the flag used to specify which material part must be marked as dirty
  33076. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33077. */
  33078. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33079. /** @hidden */ private _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;
  33080. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33081. }
  33082. }
  33083. declare module BABYLON {
  33084. /**
  33085. * Set of assets to keep when moving a scene into an asset container.
  33086. */
  33087. export class KeepAssets extends AbstractScene {
  33088. }
  33089. /**
  33090. * Container with a set of assets that can be added or removed from a scene.
  33091. */
  33092. export class AssetContainer extends AbstractScene {
  33093. /**
  33094. * The scene the AssetContainer belongs to.
  33095. */
  33096. scene: Scene;
  33097. /**
  33098. * Instantiates an AssetContainer.
  33099. * @param scene The scene the AssetContainer belongs to.
  33100. */
  33101. constructor(scene: Scene);
  33102. /**
  33103. * Adds all the assets from the container to the scene.
  33104. */
  33105. addAllToScene(): void;
  33106. /**
  33107. * Removes all the assets in the container from the scene
  33108. */
  33109. removeAllFromScene(): void;
  33110. /**
  33111. * Disposes all the assets in the container
  33112. */
  33113. dispose(): void;
  33114. private _moveAssets;
  33115. /**
  33116. * Removes all the assets contained in the scene and adds them to the container.
  33117. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33118. */
  33119. moveAllFromScene(keepAssets?: KeepAssets): void;
  33120. /**
  33121. * 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.
  33122. * @returns the root mesh
  33123. */
  33124. createRootMesh(): Mesh;
  33125. }
  33126. }
  33127. declare module BABYLON {
  33128. /**
  33129. * Defines how the parser contract is defined.
  33130. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33131. */
  33132. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33133. /**
  33134. * Defines how the individual parser contract is defined.
  33135. * These parser can parse an individual asset
  33136. */
  33137. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33138. /**
  33139. * Base class of the scene acting as a container for the different elements composing a scene.
  33140. * This class is dynamically extended by the different components of the scene increasing
  33141. * flexibility and reducing coupling
  33142. */
  33143. export abstract class AbstractScene {
  33144. /**
  33145. * Stores the list of available parsers in the application.
  33146. */
  33147. private static _BabylonFileParsers;
  33148. /**
  33149. * Stores the list of available individual parsers in the application.
  33150. */
  33151. private static _IndividualBabylonFileParsers;
  33152. /**
  33153. * Adds a parser in the list of available ones
  33154. * @param name Defines the name of the parser
  33155. * @param parser Defines the parser to add
  33156. */
  33157. static AddParser(name: string, parser: BabylonFileParser): void;
  33158. /**
  33159. * Gets a general parser from the list of avaialble ones
  33160. * @param name Defines the name of the parser
  33161. * @returns the requested parser or null
  33162. */
  33163. static GetParser(name: string): Nullable<BabylonFileParser>;
  33164. /**
  33165. * Adds n individual parser in the list of available ones
  33166. * @param name Defines the name of the parser
  33167. * @param parser Defines the parser to add
  33168. */
  33169. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33170. /**
  33171. * Gets an individual parser from the list of avaialble ones
  33172. * @param name Defines the name of the parser
  33173. * @returns the requested parser or null
  33174. */
  33175. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33176. /**
  33177. * Parser json data and populate both a scene and its associated container object
  33178. * @param jsonData Defines the data to parse
  33179. * @param scene Defines the scene to parse the data for
  33180. * @param container Defines the container attached to the parsing sequence
  33181. * @param rootUrl Defines the root url of the data
  33182. */
  33183. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33184. /**
  33185. * Gets the list of root nodes (ie. nodes with no parent)
  33186. */
  33187. rootNodes: Node[];
  33188. /** All of the cameras added to this scene
  33189. * @see http://doc.babylonjs.com/babylon101/cameras
  33190. */
  33191. cameras: Camera[];
  33192. /**
  33193. * All of the lights added to this scene
  33194. * @see http://doc.babylonjs.com/babylon101/lights
  33195. */
  33196. lights: Light[];
  33197. /**
  33198. * All of the (abstract) meshes added to this scene
  33199. */
  33200. meshes: AbstractMesh[];
  33201. /**
  33202. * The list of skeletons added to the scene
  33203. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33204. */
  33205. skeletons: Skeleton[];
  33206. /**
  33207. * All of the particle systems added to this scene
  33208. * @see http://doc.babylonjs.com/babylon101/particles
  33209. */
  33210. particleSystems: IParticleSystem[];
  33211. /**
  33212. * Gets a list of Animations associated with the scene
  33213. */
  33214. animations: Animation[];
  33215. /**
  33216. * All of the animation groups added to this scene
  33217. * @see http://doc.babylonjs.com/how_to/group
  33218. */
  33219. animationGroups: AnimationGroup[];
  33220. /**
  33221. * All of the multi-materials added to this scene
  33222. * @see http://doc.babylonjs.com/how_to/multi_materials
  33223. */
  33224. multiMaterials: MultiMaterial[];
  33225. /**
  33226. * All of the materials added to this scene
  33227. * In the context of a Scene, it is not supposed to be modified manually.
  33228. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33229. * Note also that the order of the Material wihin the array is not significant and might change.
  33230. * @see http://doc.babylonjs.com/babylon101/materials
  33231. */
  33232. materials: Material[];
  33233. /**
  33234. * The list of morph target managers added to the scene
  33235. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33236. */
  33237. morphTargetManagers: MorphTargetManager[];
  33238. /**
  33239. * The list of geometries used in the scene.
  33240. */
  33241. geometries: Geometry[];
  33242. /**
  33243. * All of the tranform nodes added to this scene
  33244. * In the context of a Scene, it is not supposed to be modified manually.
  33245. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33246. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33247. * @see http://doc.babylonjs.com/how_to/transformnode
  33248. */
  33249. transformNodes: TransformNode[];
  33250. /**
  33251. * ActionManagers available on the scene.
  33252. */
  33253. actionManagers: AbstractActionManager[];
  33254. /**
  33255. * Textures to keep.
  33256. */
  33257. textures: BaseTexture[];
  33258. /**
  33259. * Environment texture for the scene
  33260. */
  33261. environmentTexture: Nullable<BaseTexture>;
  33262. }
  33263. }
  33264. declare module BABYLON {
  33265. /**
  33266. * Defines a sound that can be played in the application.
  33267. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  33268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33269. */
  33270. export class Sound {
  33271. /**
  33272. * The name of the sound in the scene.
  33273. */
  33274. name: string;
  33275. /**
  33276. * Does the sound autoplay once loaded.
  33277. */
  33278. autoplay: boolean;
  33279. /**
  33280. * Does the sound loop after it finishes playing once.
  33281. */
  33282. loop: boolean;
  33283. /**
  33284. * Does the sound use a custom attenuation curve to simulate the falloff
  33285. * happening when the source gets further away from the camera.
  33286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33287. */
  33288. useCustomAttenuation: boolean;
  33289. /**
  33290. * The sound track id this sound belongs to.
  33291. */
  33292. soundTrackId: number;
  33293. /**
  33294. * Is this sound currently played.
  33295. */
  33296. isPlaying: boolean;
  33297. /**
  33298. * Is this sound currently paused.
  33299. */
  33300. isPaused: boolean;
  33301. /**
  33302. * Does this sound enables spatial sound.
  33303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33304. */
  33305. spatialSound: boolean;
  33306. /**
  33307. * Define the reference distance the sound should be heard perfectly.
  33308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33309. */
  33310. refDistance: number;
  33311. /**
  33312. * Define the roll off factor of spatial sounds.
  33313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33314. */
  33315. rolloffFactor: number;
  33316. /**
  33317. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  33318. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33319. */
  33320. maxDistance: number;
  33321. /**
  33322. * Define the distance attenuation model the sound will follow.
  33323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33324. */
  33325. distanceModel: string;
  33326. /**
  33327. * @hidden
  33328. * Back Compat
  33329. **/
  33330. onended: () => any;
  33331. /**
  33332. * Observable event when the current playing sound finishes.
  33333. */
  33334. onEndedObservable: Observable<Sound>;
  33335. private _panningModel;
  33336. private _playbackRate;
  33337. private _streaming;
  33338. private _startTime;
  33339. private _startOffset;
  33340. private _position;
  33341. /** @hidden */ private _positionInEmitterSpace: boolean;
  33342. private _localDirection;
  33343. private _volume;
  33344. private _isReadyToPlay;
  33345. private _isDirectional;
  33346. private _readyToPlayCallback;
  33347. private _audioBuffer;
  33348. private _soundSource;
  33349. private _streamingSource;
  33350. private _soundPanner;
  33351. private _soundGain;
  33352. private _inputAudioNode;
  33353. private _outputAudioNode;
  33354. private _coneInnerAngle;
  33355. private _coneOuterAngle;
  33356. private _coneOuterGain;
  33357. private _scene;
  33358. private _connectedTransformNode;
  33359. private _customAttenuationFunction;
  33360. private _registerFunc;
  33361. private _isOutputConnected;
  33362. private _htmlAudioElement;
  33363. private _urlType;
  33364. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  33365. /**
  33366. * Create a sound and attach it to a scene
  33367. * @param name Name of your sound
  33368. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  33369. * @param scene defines the scene the sound belongs to
  33370. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  33371. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  33372. */
  33373. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  33374. /**
  33375. * Release the sound and its associated resources
  33376. */
  33377. dispose(): void;
  33378. /**
  33379. * Gets if the sounds is ready to be played or not.
  33380. * @returns true if ready, otherwise false
  33381. */
  33382. isReady(): boolean;
  33383. private _soundLoaded;
  33384. /**
  33385. * Sets the data of the sound from an audiobuffer
  33386. * @param audioBuffer The audioBuffer containing the data
  33387. */
  33388. setAudioBuffer(audioBuffer: AudioBuffer): void;
  33389. /**
  33390. * Updates the current sounds options such as maxdistance, loop...
  33391. * @param options A JSON object containing values named as the object properties
  33392. */
  33393. updateOptions(options: any): void;
  33394. private _createSpatialParameters;
  33395. private _updateSpatialParameters;
  33396. /**
  33397. * Switch the panning model to HRTF:
  33398. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33400. */
  33401. switchPanningModelToHRTF(): void;
  33402. /**
  33403. * Switch the panning model to Equal Power:
  33404. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33406. */
  33407. switchPanningModelToEqualPower(): void;
  33408. private _switchPanningModel;
  33409. /**
  33410. * Connect this sound to a sound track audio node like gain...
  33411. * @param soundTrackAudioNode the sound track audio node to connect to
  33412. */
  33413. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  33414. /**
  33415. * Transform this sound into a directional source
  33416. * @param coneInnerAngle Size of the inner cone in degree
  33417. * @param coneOuterAngle Size of the outer cone in degree
  33418. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  33419. */
  33420. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  33421. /**
  33422. * Gets or sets the inner angle for the directional cone.
  33423. */
  33424. /**
  33425. * Gets or sets the inner angle for the directional cone.
  33426. */
  33427. directionalConeInnerAngle: number;
  33428. /**
  33429. * Gets or sets the outer angle for the directional cone.
  33430. */
  33431. /**
  33432. * Gets or sets the outer angle for the directional cone.
  33433. */
  33434. directionalConeOuterAngle: number;
  33435. /**
  33436. * Sets the position of the emitter if spatial sound is enabled
  33437. * @param newPosition Defines the new posisiton
  33438. */
  33439. setPosition(newPosition: Vector3): void;
  33440. /**
  33441. * Sets the local direction of the emitter if spatial sound is enabled
  33442. * @param newLocalDirection Defines the new local direction
  33443. */
  33444. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  33445. private _updateDirection;
  33446. /** @hidden */
  33447. updateDistanceFromListener(): void;
  33448. /**
  33449. * Sets a new custom attenuation function for the sound.
  33450. * @param callback Defines the function used for the attenuation
  33451. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  33452. */
  33453. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  33454. /**
  33455. * Play the sound
  33456. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  33457. * @param offset (optional) Start the sound setting it at a specific time
  33458. */
  33459. play(time?: number, offset?: number): void;
  33460. private _onended;
  33461. /**
  33462. * Stop the sound
  33463. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  33464. */
  33465. stop(time?: number): void;
  33466. /**
  33467. * Put the sound in pause
  33468. */
  33469. pause(): void;
  33470. /**
  33471. * Sets a dedicated volume for this sounds
  33472. * @param newVolume Define the new volume of the sound
  33473. * @param time Define in how long the sound should be at this value
  33474. */
  33475. setVolume(newVolume: number, time?: number): void;
  33476. /**
  33477. * Set the sound play back rate
  33478. * @param newPlaybackRate Define the playback rate the sound should be played at
  33479. */
  33480. setPlaybackRate(newPlaybackRate: number): void;
  33481. /**
  33482. * Gets the volume of the sound.
  33483. * @returns the volume of the sound
  33484. */
  33485. getVolume(): number;
  33486. /**
  33487. * Attach the sound to a dedicated mesh
  33488. * @param transformNode The transform node to connect the sound with
  33489. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33490. */
  33491. attachToMesh(transformNode: TransformNode): void;
  33492. /**
  33493. * Detach the sound from the previously attached mesh
  33494. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  33495. */
  33496. detachFromMesh(): void;
  33497. private _onRegisterAfterWorldMatrixUpdate;
  33498. /**
  33499. * Clone the current sound in the scene.
  33500. * @returns the new sound clone
  33501. */
  33502. clone(): Nullable<Sound>;
  33503. /**
  33504. * Gets the current underlying audio buffer containing the data
  33505. * @returns the audio buffer
  33506. */
  33507. getAudioBuffer(): Nullable<AudioBuffer>;
  33508. /**
  33509. * Serializes the Sound in a JSON representation
  33510. * @returns the JSON representation of the sound
  33511. */
  33512. serialize(): any;
  33513. /**
  33514. * Parse a JSON representation of a sound to innstantiate in a given scene
  33515. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  33516. * @param scene Define the scene the new parsed sound should be created in
  33517. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  33518. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  33519. * @returns the newly parsed sound
  33520. */
  33521. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  33522. }
  33523. }
  33524. declare module BABYLON {
  33525. /**
  33526. * This defines an action helpful to play a defined sound on a triggered action.
  33527. */
  33528. export class PlaySoundAction extends Action {
  33529. private _sound;
  33530. /**
  33531. * Instantiate the action
  33532. * @param triggerOptions defines the trigger options
  33533. * @param sound defines the sound to play
  33534. * @param condition defines the trigger related conditions
  33535. */
  33536. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33537. /** @hidden */ private _prepare(): void;
  33538. /**
  33539. * Execute the action and play the sound.
  33540. */
  33541. execute(): void;
  33542. /**
  33543. * Serializes the actions and its related information.
  33544. * @param parent defines the object to serialize in
  33545. * @returns the serialized object
  33546. */
  33547. serialize(parent: any): any;
  33548. }
  33549. /**
  33550. * This defines an action helpful to stop a defined sound on a triggered action.
  33551. */
  33552. export class StopSoundAction extends Action {
  33553. private _sound;
  33554. /**
  33555. * Instantiate the action
  33556. * @param triggerOptions defines the trigger options
  33557. * @param sound defines the sound to stop
  33558. * @param condition defines the trigger related conditions
  33559. */
  33560. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  33561. /** @hidden */ private _prepare(): void;
  33562. /**
  33563. * Execute the action and stop the sound.
  33564. */
  33565. execute(): void;
  33566. /**
  33567. * Serializes the actions and its related information.
  33568. * @param parent defines the object to serialize in
  33569. * @returns the serialized object
  33570. */
  33571. serialize(parent: any): any;
  33572. }
  33573. }
  33574. declare module BABYLON {
  33575. /**
  33576. * This defines an action responsible to change the value of a property
  33577. * by interpolating between its current value and the newly set one once triggered.
  33578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33579. */
  33580. export class InterpolateValueAction extends Action {
  33581. /**
  33582. * Defines the path of the property where the value should be interpolated
  33583. */
  33584. propertyPath: string;
  33585. /**
  33586. * Defines the target value at the end of the interpolation.
  33587. */
  33588. value: any;
  33589. /**
  33590. * Defines the time it will take for the property to interpolate to the value.
  33591. */
  33592. duration: number;
  33593. /**
  33594. * Defines if the other scene animations should be stopped when the action has been triggered
  33595. */
  33596. stopOtherAnimations?: boolean;
  33597. /**
  33598. * Defines a callback raised once the interpolation animation has been done.
  33599. */
  33600. onInterpolationDone?: () => void;
  33601. /**
  33602. * Observable triggered once the interpolation animation has been done.
  33603. */
  33604. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  33605. private _target;
  33606. private _effectiveTarget;
  33607. private _property;
  33608. /**
  33609. * Instantiate the action
  33610. * @param triggerOptions defines the trigger options
  33611. * @param target defines the object containing the value to interpolate
  33612. * @param propertyPath defines the path to the property in the target object
  33613. * @param value defines the target value at the end of the interpolation
  33614. * @param duration deines the time it will take for the property to interpolate to the value.
  33615. * @param condition defines the trigger related conditions
  33616. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  33617. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  33618. */
  33619. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  33620. /** @hidden */ private _prepare(): void;
  33621. /**
  33622. * Execute the action starts the value interpolation.
  33623. */
  33624. execute(): void;
  33625. /**
  33626. * Serializes the actions and its related information.
  33627. * @param parent defines the object to serialize in
  33628. * @returns the serialized object
  33629. */
  33630. serialize(parent: any): any;
  33631. }
  33632. }
  33633. declare module BABYLON {
  33634. /**
  33635. * Options allowed during the creation of a sound track.
  33636. */
  33637. export interface ISoundTrackOptions {
  33638. /**
  33639. * The volume the sound track should take during creation
  33640. */
  33641. volume?: number;
  33642. /**
  33643. * Define if the sound track is the main sound track of the scene
  33644. */
  33645. mainTrack?: boolean;
  33646. }
  33647. /**
  33648. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  33649. * It will be also used in a future release to apply effects on a specific track.
  33650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33651. */
  33652. export class SoundTrack {
  33653. /**
  33654. * The unique identifier of the sound track in the scene.
  33655. */
  33656. id: number;
  33657. /**
  33658. * The list of sounds included in the sound track.
  33659. */
  33660. soundCollection: Array<Sound>;
  33661. private _outputAudioNode;
  33662. private _scene;
  33663. private _isMainTrack;
  33664. private _connectedAnalyser;
  33665. private _options;
  33666. private _isInitialized;
  33667. /**
  33668. * Creates a new sound track.
  33669. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  33670. * @param scene Define the scene the sound track belongs to
  33671. * @param options
  33672. */
  33673. constructor(scene: Scene, options?: ISoundTrackOptions);
  33674. private _initializeSoundTrackAudioGraph;
  33675. /**
  33676. * Release the sound track and its associated resources
  33677. */
  33678. dispose(): void;
  33679. /**
  33680. * Adds a sound to this sound track
  33681. * @param sound define the cound to add
  33682. * @ignoreNaming
  33683. */
  33684. AddSound(sound: Sound): void;
  33685. /**
  33686. * Removes a sound to this sound track
  33687. * @param sound define the cound to remove
  33688. * @ignoreNaming
  33689. */
  33690. RemoveSound(sound: Sound): void;
  33691. /**
  33692. * Set a global volume for the full sound track.
  33693. * @param newVolume Define the new volume of the sound track
  33694. */
  33695. setVolume(newVolume: number): void;
  33696. /**
  33697. * Switch the panning model to HRTF:
  33698. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  33699. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33700. */
  33701. switchPanningModelToHRTF(): void;
  33702. /**
  33703. * Switch the panning model to Equal Power:
  33704. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  33705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33706. */
  33707. switchPanningModelToEqualPower(): void;
  33708. /**
  33709. * Connect the sound track to an audio analyser allowing some amazing
  33710. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33712. * @param analyser The analyser to connect to the engine
  33713. */
  33714. connectToAnalyser(analyser: Analyser): void;
  33715. }
  33716. }
  33717. declare module BABYLON {
  33718. interface AbstractScene {
  33719. /**
  33720. * The list of sounds used in the scene.
  33721. */
  33722. sounds: Nullable<Array<Sound>>;
  33723. }
  33724. interface Scene {
  33725. /**
  33726. * @hidden
  33727. * Backing field
  33728. */ private _mainSoundTrack: SoundTrack;
  33729. /**
  33730. * The main sound track played by the scene.
  33731. * It cotains your primary collection of sounds.
  33732. */
  33733. mainSoundTrack: SoundTrack;
  33734. /**
  33735. * The list of sound tracks added to the scene
  33736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33737. */
  33738. soundTracks: Nullable<Array<SoundTrack>>;
  33739. /**
  33740. * Gets a sound using a given name
  33741. * @param name defines the name to search for
  33742. * @return the found sound or null if not found at all.
  33743. */
  33744. getSoundByName(name: string): Nullable<Sound>;
  33745. /**
  33746. * Gets or sets if audio support is enabled
  33747. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33748. */
  33749. audioEnabled: boolean;
  33750. /**
  33751. * Gets or sets if audio will be output to headphones
  33752. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33753. */
  33754. headphone: boolean;
  33755. }
  33756. /**
  33757. * Defines the sound scene component responsible to manage any sounds
  33758. * in a given scene.
  33759. */
  33760. export class AudioSceneComponent implements ISceneSerializableComponent {
  33761. /**
  33762. * The component name helpfull to identify the component in the list of scene components.
  33763. */
  33764. readonly name: string;
  33765. /**
  33766. * The scene the component belongs to.
  33767. */
  33768. scene: Scene;
  33769. private _audioEnabled;
  33770. /**
  33771. * Gets whether audio is enabled or not.
  33772. * Please use related enable/disable method to switch state.
  33773. */
  33774. readonly audioEnabled: boolean;
  33775. private _headphone;
  33776. /**
  33777. * Gets whether audio is outputing to headphone or not.
  33778. * Please use the according Switch methods to change output.
  33779. */
  33780. readonly headphone: boolean;
  33781. /**
  33782. * Creates a new instance of the component for the given scene
  33783. * @param scene Defines the scene to register the component in
  33784. */
  33785. constructor(scene: Scene);
  33786. /**
  33787. * Registers the component in a given scene
  33788. */
  33789. register(): void;
  33790. /**
  33791. * Rebuilds the elements related to this component in case of
  33792. * context lost for instance.
  33793. */
  33794. rebuild(): void;
  33795. /**
  33796. * Serializes the component data to the specified json object
  33797. * @param serializationObject The object to serialize to
  33798. */
  33799. serialize(serializationObject: any): void;
  33800. /**
  33801. * Adds all the elements from the container to the scene
  33802. * @param container the container holding the elements
  33803. */
  33804. addFromContainer(container: AbstractScene): void;
  33805. /**
  33806. * Removes all the elements in the container from the scene
  33807. * @param container contains the elements to remove
  33808. * @param dispose if the removed element should be disposed (default: false)
  33809. */
  33810. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  33811. /**
  33812. * Disposes the component and the associated ressources.
  33813. */
  33814. dispose(): void;
  33815. /**
  33816. * Disables audio in the associated scene.
  33817. */
  33818. disableAudio(): void;
  33819. /**
  33820. * Enables audio in the associated scene.
  33821. */
  33822. enableAudio(): void;
  33823. /**
  33824. * Switch audio to headphone output.
  33825. */
  33826. switchAudioModeForHeadphones(): void;
  33827. /**
  33828. * Switch audio to normal speakers.
  33829. */
  33830. switchAudioModeForNormalSpeakers(): void;
  33831. private _afterRender;
  33832. }
  33833. }
  33834. declare module BABYLON {
  33835. /**
  33836. * Wraps one or more Sound objects and selects one with random weight for playback.
  33837. */
  33838. export class WeightedSound {
  33839. /** When true a Sound will be selected and played when the current playing Sound completes. */
  33840. loop: boolean;
  33841. private _coneInnerAngle;
  33842. private _coneOuterAngle;
  33843. private _volume;
  33844. /** A Sound is currently playing. */
  33845. isPlaying: boolean;
  33846. /** A Sound is currently paused. */
  33847. isPaused: boolean;
  33848. private _sounds;
  33849. private _weights;
  33850. private _currentIndex?;
  33851. /**
  33852. * Creates a new WeightedSound from the list of sounds given.
  33853. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  33854. * @param sounds Array of Sounds that will be selected from.
  33855. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  33856. */
  33857. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  33858. /**
  33859. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  33860. */
  33861. /**
  33862. * The size of cone in degress for a directional sound in which there will be no attenuation.
  33863. */
  33864. directionalConeInnerAngle: number;
  33865. /**
  33866. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33867. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33868. */
  33869. /**
  33870. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  33871. * Listener angles between innerAngle and outerAngle will falloff linearly.
  33872. */
  33873. directionalConeOuterAngle: number;
  33874. /**
  33875. * Playback volume.
  33876. */
  33877. /**
  33878. * Playback volume.
  33879. */
  33880. volume: number;
  33881. private _onended;
  33882. /**
  33883. * Suspend playback
  33884. */
  33885. pause(): void;
  33886. /**
  33887. * Stop playback
  33888. */
  33889. stop(): void;
  33890. /**
  33891. * Start playback.
  33892. * @param startOffset Position the clip head at a specific time in seconds.
  33893. */
  33894. play(startOffset?: number): void;
  33895. }
  33896. }
  33897. declare module BABYLON {
  33898. /**
  33899. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  33900. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  33901. */
  33902. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  33903. /**
  33904. * Gets the name of the behavior.
  33905. */
  33906. readonly name: string;
  33907. /**
  33908. * The easing function used by animations
  33909. */
  33910. static EasingFunction: BackEase;
  33911. /**
  33912. * The easing mode used by animations
  33913. */
  33914. static EasingMode: number;
  33915. /**
  33916. * The duration of the animation, in milliseconds
  33917. */
  33918. transitionDuration: number;
  33919. /**
  33920. * Length of the distance animated by the transition when lower radius is reached
  33921. */
  33922. lowerRadiusTransitionRange: number;
  33923. /**
  33924. * Length of the distance animated by the transition when upper radius is reached
  33925. */
  33926. upperRadiusTransitionRange: number;
  33927. private _autoTransitionRange;
  33928. /**
  33929. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33930. */
  33931. /**
  33932. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  33933. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  33934. */
  33935. autoTransitionRange: boolean;
  33936. private _attachedCamera;
  33937. private _onAfterCheckInputsObserver;
  33938. private _onMeshTargetChangedObserver;
  33939. /**
  33940. * Initializes the behavior.
  33941. */
  33942. init(): void;
  33943. /**
  33944. * Attaches the behavior to its arc rotate camera.
  33945. * @param camera Defines the camera to attach the behavior to
  33946. */
  33947. attach(camera: ArcRotateCamera): void;
  33948. /**
  33949. * Detaches the behavior from its current arc rotate camera.
  33950. */
  33951. detach(): void;
  33952. private _radiusIsAnimating;
  33953. private _radiusBounceTransition;
  33954. private _animatables;
  33955. private _cachedWheelPrecision;
  33956. /**
  33957. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  33958. * @param radiusLimit The limit to check against.
  33959. * @return Bool to indicate if at limit.
  33960. */
  33961. private _isRadiusAtLimit;
  33962. /**
  33963. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  33964. * @param radiusDelta The delta by which to animate to. Can be negative.
  33965. */
  33966. private _applyBoundRadiusAnimation;
  33967. /**
  33968. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  33969. */
  33970. protected _clearAnimationLocks(): void;
  33971. /**
  33972. * Stops and removes all animations that have been applied to the camera
  33973. */
  33974. stopAllAnimations(): void;
  33975. }
  33976. }
  33977. declare module BABYLON {
  33978. /**
  33979. * 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.
  33980. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  33981. */
  33982. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  33983. /**
  33984. * Gets the name of the behavior.
  33985. */
  33986. readonly name: string;
  33987. private _mode;
  33988. private _radiusScale;
  33989. private _positionScale;
  33990. private _defaultElevation;
  33991. private _elevationReturnTime;
  33992. private _elevationReturnWaitTime;
  33993. private _zoomStopsAnimation;
  33994. private _framingTime;
  33995. /**
  33996. * The easing function used by animations
  33997. */
  33998. static EasingFunction: ExponentialEase;
  33999. /**
  34000. * The easing mode used by animations
  34001. */
  34002. static EasingMode: number;
  34003. /**
  34004. * Sets the current mode used by the behavior
  34005. */
  34006. /**
  34007. * Gets current mode used by the behavior.
  34008. */
  34009. mode: number;
  34010. /**
  34011. * Sets the scale applied to the radius (1 by default)
  34012. */
  34013. /**
  34014. * Gets the scale applied to the radius
  34015. */
  34016. radiusScale: number;
  34017. /**
  34018. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34019. */
  34020. /**
  34021. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34022. */
  34023. positionScale: number;
  34024. /**
  34025. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34026. * behaviour is triggered, in radians.
  34027. */
  34028. /**
  34029. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34030. * behaviour is triggered, in radians.
  34031. */
  34032. defaultElevation: number;
  34033. /**
  34034. * Sets the time (in milliseconds) taken to return to the default beta position.
  34035. * Negative value indicates camera should not return to default.
  34036. */
  34037. /**
  34038. * Gets the time (in milliseconds) taken to return to the default beta position.
  34039. * Negative value indicates camera should not return to default.
  34040. */
  34041. elevationReturnTime: number;
  34042. /**
  34043. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34044. */
  34045. /**
  34046. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34047. */
  34048. elevationReturnWaitTime: number;
  34049. /**
  34050. * Sets the flag that indicates if user zooming should stop animation.
  34051. */
  34052. /**
  34053. * Gets the flag that indicates if user zooming should stop animation.
  34054. */
  34055. zoomStopsAnimation: boolean;
  34056. /**
  34057. * Sets the transition time when framing the mesh, in milliseconds
  34058. */
  34059. /**
  34060. * Gets the transition time when framing the mesh, in milliseconds
  34061. */
  34062. framingTime: number;
  34063. /**
  34064. * Define if the behavior should automatically change the configured
  34065. * camera limits and sensibilities.
  34066. */
  34067. autoCorrectCameraLimitsAndSensibility: boolean;
  34068. private _onPrePointerObservableObserver;
  34069. private _onAfterCheckInputsObserver;
  34070. private _onMeshTargetChangedObserver;
  34071. private _attachedCamera;
  34072. private _isPointerDown;
  34073. private _lastInteractionTime;
  34074. /**
  34075. * Initializes the behavior.
  34076. */
  34077. init(): void;
  34078. /**
  34079. * Attaches the behavior to its arc rotate camera.
  34080. * @param camera Defines the camera to attach the behavior to
  34081. */
  34082. attach(camera: ArcRotateCamera): void;
  34083. /**
  34084. * Detaches the behavior from its current arc rotate camera.
  34085. */
  34086. detach(): void;
  34087. private _animatables;
  34088. private _betaIsAnimating;
  34089. private _betaTransition;
  34090. private _radiusTransition;
  34091. private _vectorTransition;
  34092. /**
  34093. * Targets the given mesh and updates zoom level accordingly.
  34094. * @param mesh The mesh to target.
  34095. * @param radius Optional. If a cached radius position already exists, overrides default.
  34096. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34097. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34098. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34099. */
  34100. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34101. /**
  34102. * Targets the given mesh with its children and updates zoom level accordingly.
  34103. * @param mesh The mesh to target.
  34104. * @param radius Optional. If a cached radius position already exists, overrides default.
  34105. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34106. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34107. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34108. */
  34109. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34110. /**
  34111. * Targets the given meshes with their children and updates zoom level accordingly.
  34112. * @param meshes The mesh to target.
  34113. * @param radius Optional. If a cached radius position already exists, overrides default.
  34114. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34115. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34116. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34117. */
  34118. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34119. /**
  34120. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34121. * @param minimumWorld Determines the smaller position of the bounding box extend
  34122. * @param maximumWorld Determines the bigger position of the bounding box extend
  34123. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34124. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34125. */
  34126. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34127. /**
  34128. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34129. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34130. * frustum width.
  34131. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34132. * to fully enclose the mesh in the viewing frustum.
  34133. */
  34134. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34135. /**
  34136. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34137. * is automatically returned to its default position (expected to be above ground plane).
  34138. */
  34139. private _maintainCameraAboveGround;
  34140. /**
  34141. * Returns the frustum slope based on the canvas ratio and camera FOV
  34142. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34143. */
  34144. private _getFrustumSlope;
  34145. /**
  34146. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34147. */
  34148. private _clearAnimationLocks;
  34149. /**
  34150. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34151. */
  34152. private _applyUserInteraction;
  34153. /**
  34154. * Stops and removes all animations that have been applied to the camera
  34155. */
  34156. stopAllAnimations(): void;
  34157. /**
  34158. * Gets a value indicating if the user is moving the camera
  34159. */
  34160. readonly isUserIsMoving: boolean;
  34161. /**
  34162. * The camera can move all the way towards the mesh.
  34163. */
  34164. static IgnoreBoundsSizeMode: number;
  34165. /**
  34166. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34167. */
  34168. static FitFrustumSidesMode: number;
  34169. }
  34170. }
  34171. declare module BABYLON {
  34172. /**
  34173. * Base class for Camera Pointer Inputs.
  34174. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34175. * for example usage.
  34176. */
  34177. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34178. /**
  34179. * Defines the camera the input is attached to.
  34180. */
  34181. abstract camera: Camera;
  34182. /**
  34183. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34184. */
  34185. protected _altKey: boolean;
  34186. protected _ctrlKey: boolean;
  34187. protected _metaKey: boolean;
  34188. protected _shiftKey: boolean;
  34189. /**
  34190. * Which mouse buttons were pressed at time of last mouse event.
  34191. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34192. */
  34193. protected _buttonsPressed: number;
  34194. /**
  34195. * Defines the buttons associated with the input to handle camera move.
  34196. */
  34197. buttons: number[];
  34198. /**
  34199. * Attach the input controls to a specific dom element to get the input from.
  34200. * @param element Defines the element the controls should be listened from
  34201. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34202. */
  34203. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34204. /**
  34205. * Detach the current controls from the specified dom element.
  34206. * @param element Defines the element to stop listening the inputs from
  34207. */
  34208. detachControl(element: Nullable<HTMLElement>): void;
  34209. /**
  34210. * Gets the class name of the current input.
  34211. * @returns the class name
  34212. */
  34213. getClassName(): string;
  34214. /**
  34215. * Get the friendly name associated with the input class.
  34216. * @returns the input friendly name
  34217. */
  34218. getSimpleName(): string;
  34219. /**
  34220. * Called on pointer POINTERDOUBLETAP event.
  34221. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34222. */
  34223. protected onDoubleTap(type: string): void;
  34224. /**
  34225. * Called on pointer POINTERMOVE event if only a single touch is active.
  34226. * Override this method to provide functionality.
  34227. */
  34228. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34229. /**
  34230. * Called on pointer POINTERMOVE event if multiple touches are active.
  34231. * Override this method to provide functionality.
  34232. */
  34233. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34234. /**
  34235. * Called on JS contextmenu event.
  34236. * Override this method to provide functionality.
  34237. */
  34238. protected onContextMenu(evt: PointerEvent): void;
  34239. /**
  34240. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34241. * press.
  34242. * Override this method to provide functionality.
  34243. */
  34244. protected onButtonDown(evt: PointerEvent): void;
  34245. /**
  34246. * Called each time a new POINTERUP event occurs. Ie, for each button
  34247. * release.
  34248. * Override this method to provide functionality.
  34249. */
  34250. protected onButtonUp(evt: PointerEvent): void;
  34251. /**
  34252. * Called when window becomes inactive.
  34253. * Override this method to provide functionality.
  34254. */
  34255. protected onLostFocus(): void;
  34256. private _pointerInput;
  34257. private _observer;
  34258. private _onLostFocus;
  34259. private pointA;
  34260. private pointB;
  34261. }
  34262. }
  34263. declare module BABYLON {
  34264. /**
  34265. * Manage the pointers inputs to control an arc rotate camera.
  34266. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34267. */
  34268. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  34269. /**
  34270. * Defines the camera the input is attached to.
  34271. */
  34272. camera: ArcRotateCamera;
  34273. /**
  34274. * Gets the class name of the current input.
  34275. * @returns the class name
  34276. */
  34277. getClassName(): string;
  34278. /**
  34279. * Defines the buttons associated with the input to handle camera move.
  34280. */
  34281. buttons: number[];
  34282. /**
  34283. * Defines the pointer angular sensibility along the X axis or how fast is
  34284. * the camera rotating.
  34285. */
  34286. angularSensibilityX: number;
  34287. /**
  34288. * Defines the pointer angular sensibility along the Y axis or how fast is
  34289. * the camera rotating.
  34290. */
  34291. angularSensibilityY: number;
  34292. /**
  34293. * Defines the pointer pinch precision or how fast is the camera zooming.
  34294. */
  34295. pinchPrecision: number;
  34296. /**
  34297. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  34298. * from 0.
  34299. * It defines the percentage of current camera.radius to use as delta when
  34300. * pinch zoom is used.
  34301. */
  34302. pinchDeltaPercentage: number;
  34303. /**
  34304. * Defines the pointer panning sensibility or how fast is the camera moving.
  34305. */
  34306. panningSensibility: number;
  34307. /**
  34308. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  34309. */
  34310. multiTouchPanning: boolean;
  34311. /**
  34312. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  34313. * zoom (pinch) through multitouch.
  34314. */
  34315. multiTouchPanAndZoom: boolean;
  34316. /**
  34317. * Revers pinch action direction.
  34318. */
  34319. pinchInwards: boolean;
  34320. private _isPanClick;
  34321. private _twoFingerActivityCount;
  34322. private _isPinching;
  34323. /**
  34324. * Called on pointer POINTERMOVE event if only a single touch is active.
  34325. */
  34326. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  34327. /**
  34328. * Called on pointer POINTERDOUBLETAP event.
  34329. */
  34330. protected onDoubleTap(type: string): void;
  34331. /**
  34332. * Called on pointer POINTERMOVE event if multiple touches are active.
  34333. */
  34334. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  34335. /**
  34336. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  34337. * press.
  34338. */
  34339. protected onButtonDown(evt: PointerEvent): void;
  34340. /**
  34341. * Called each time a new POINTERUP event occurs. Ie, for each button
  34342. * release.
  34343. */
  34344. protected onButtonUp(evt: PointerEvent): void;
  34345. /**
  34346. * Called when window becomes inactive.
  34347. */
  34348. protected onLostFocus(): void;
  34349. }
  34350. }
  34351. declare module BABYLON {
  34352. /**
  34353. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  34354. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34355. */
  34356. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  34357. /**
  34358. * Defines the camera the input is attached to.
  34359. */
  34360. camera: ArcRotateCamera;
  34361. /**
  34362. * Defines the list of key codes associated with the up action (increase alpha)
  34363. */
  34364. keysUp: number[];
  34365. /**
  34366. * Defines the list of key codes associated with the down action (decrease alpha)
  34367. */
  34368. keysDown: number[];
  34369. /**
  34370. * Defines the list of key codes associated with the left action (increase beta)
  34371. */
  34372. keysLeft: number[];
  34373. /**
  34374. * Defines the list of key codes associated with the right action (decrease beta)
  34375. */
  34376. keysRight: number[];
  34377. /**
  34378. * Defines the list of key codes associated with the reset action.
  34379. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  34380. */
  34381. keysReset: number[];
  34382. /**
  34383. * Defines the panning sensibility of the inputs.
  34384. * (How fast is the camera paning)
  34385. */
  34386. panningSensibility: number;
  34387. /**
  34388. * Defines the zooming sensibility of the inputs.
  34389. * (How fast is the camera zooming)
  34390. */
  34391. zoomingSensibility: number;
  34392. /**
  34393. * Defines wether maintaining the alt key down switch the movement mode from
  34394. * orientation to zoom.
  34395. */
  34396. useAltToZoom: boolean;
  34397. /**
  34398. * Rotation speed of the camera
  34399. */
  34400. angularSpeed: number;
  34401. private _keys;
  34402. private _ctrlPressed;
  34403. private _altPressed;
  34404. private _onCanvasBlurObserver;
  34405. private _onKeyboardObserver;
  34406. private _engine;
  34407. private _scene;
  34408. /**
  34409. * Attach the input controls to a specific dom element to get the input from.
  34410. * @param element Defines the element the controls should be listened from
  34411. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34412. */
  34413. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34414. /**
  34415. * Detach the current controls from the specified dom element.
  34416. * @param element Defines the element to stop listening the inputs from
  34417. */
  34418. detachControl(element: Nullable<HTMLElement>): void;
  34419. /**
  34420. * Update the current camera state depending on the inputs that have been used this frame.
  34421. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  34422. */
  34423. checkInputs(): void;
  34424. /**
  34425. * Gets the class name of the current intput.
  34426. * @returns the class name
  34427. */
  34428. getClassName(): string;
  34429. /**
  34430. * Get the friendly name associated with the input class.
  34431. * @returns the input friendly name
  34432. */
  34433. getSimpleName(): string;
  34434. }
  34435. }
  34436. declare module BABYLON {
  34437. /**
  34438. * Manage the mouse wheel inputs to control an arc rotate camera.
  34439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34440. */
  34441. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  34442. /**
  34443. * Defines the camera the input is attached to.
  34444. */
  34445. camera: ArcRotateCamera;
  34446. /**
  34447. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34448. */
  34449. wheelPrecision: number;
  34450. /**
  34451. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  34452. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  34453. */
  34454. wheelDeltaPercentage: number;
  34455. private _wheel;
  34456. private _observer;
  34457. private computeDeltaFromMouseWheelLegacyEvent;
  34458. /**
  34459. * Attach the input controls to a specific dom element to get the input from.
  34460. * @param element Defines the element the controls should be listened from
  34461. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34462. */
  34463. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34464. /**
  34465. * Detach the current controls from the specified dom element.
  34466. * @param element Defines the element to stop listening the inputs from
  34467. */
  34468. detachControl(element: Nullable<HTMLElement>): void;
  34469. /**
  34470. * Gets the class name of the current intput.
  34471. * @returns the class name
  34472. */
  34473. getClassName(): string;
  34474. /**
  34475. * Get the friendly name associated with the input class.
  34476. * @returns the input friendly name
  34477. */
  34478. getSimpleName(): string;
  34479. }
  34480. }
  34481. declare module BABYLON {
  34482. /**
  34483. * Default Inputs manager for the ArcRotateCamera.
  34484. * It groups all the default supported inputs for ease of use.
  34485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  34486. */
  34487. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  34488. /**
  34489. * Instantiates a new ArcRotateCameraInputsManager.
  34490. * @param camera Defines the camera the inputs belong to
  34491. */
  34492. constructor(camera: ArcRotateCamera);
  34493. /**
  34494. * Add mouse wheel input support to the input manager.
  34495. * @returns the current input manager
  34496. */
  34497. addMouseWheel(): ArcRotateCameraInputsManager;
  34498. /**
  34499. * Add pointers input support to the input manager.
  34500. * @returns the current input manager
  34501. */
  34502. addPointers(): ArcRotateCameraInputsManager;
  34503. /**
  34504. * Add keyboard input support to the input manager.
  34505. * @returns the current input manager
  34506. */
  34507. addKeyboard(): ArcRotateCameraInputsManager;
  34508. }
  34509. }
  34510. declare module BABYLON {
  34511. /**
  34512. * This represents an orbital type of camera.
  34513. *
  34514. * 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.
  34515. * 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.
  34516. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  34517. */
  34518. export class ArcRotateCamera extends TargetCamera {
  34519. /**
  34520. * Defines the rotation angle of the camera along the longitudinal axis.
  34521. */
  34522. alpha: number;
  34523. /**
  34524. * Defines the rotation angle of the camera along the latitudinal axis.
  34525. */
  34526. beta: number;
  34527. /**
  34528. * Defines the radius of the camera from it s target point.
  34529. */
  34530. radius: number;
  34531. protected _target: Vector3;
  34532. protected _targetHost: Nullable<AbstractMesh>;
  34533. /**
  34534. * Defines the target point of the camera.
  34535. * The camera looks towards it form the radius distance.
  34536. */
  34537. target: Vector3;
  34538. /**
  34539. * Define the current local position of the camera in the scene
  34540. */
  34541. position: Vector3;
  34542. protected _upVector: Vector3;
  34543. protected _upToYMatrix: Matrix;
  34544. protected _YToUpMatrix: Matrix;
  34545. /**
  34546. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  34547. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  34548. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  34549. */
  34550. upVector: Vector3;
  34551. /**
  34552. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  34553. */
  34554. setMatUp(): void;
  34555. /**
  34556. * Current inertia value on the longitudinal axis.
  34557. * The bigger this number the longer it will take for the camera to stop.
  34558. */
  34559. inertialAlphaOffset: number;
  34560. /**
  34561. * Current inertia value on the latitudinal axis.
  34562. * The bigger this number the longer it will take for the camera to stop.
  34563. */
  34564. inertialBetaOffset: number;
  34565. /**
  34566. * Current inertia value on the radius axis.
  34567. * The bigger this number the longer it will take for the camera to stop.
  34568. */
  34569. inertialRadiusOffset: number;
  34570. /**
  34571. * Minimum allowed angle on the longitudinal axis.
  34572. * This can help limiting how the Camera is able to move in the scene.
  34573. */
  34574. lowerAlphaLimit: Nullable<number>;
  34575. /**
  34576. * Maximum allowed angle on the longitudinal axis.
  34577. * This can help limiting how the Camera is able to move in the scene.
  34578. */
  34579. upperAlphaLimit: Nullable<number>;
  34580. /**
  34581. * Minimum allowed angle on the latitudinal axis.
  34582. * This can help limiting how the Camera is able to move in the scene.
  34583. */
  34584. lowerBetaLimit: number;
  34585. /**
  34586. * Maximum allowed angle on the latitudinal axis.
  34587. * This can help limiting how the Camera is able to move in the scene.
  34588. */
  34589. upperBetaLimit: number;
  34590. /**
  34591. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  34592. * This can help limiting how the Camera is able to move in the scene.
  34593. */
  34594. lowerRadiusLimit: Nullable<number>;
  34595. /**
  34596. * Maximum allowed distance of the camera to the target (The camera can not get further).
  34597. * This can help limiting how the Camera is able to move in the scene.
  34598. */
  34599. upperRadiusLimit: Nullable<number>;
  34600. /**
  34601. * Defines the current inertia value used during panning of the camera along the X axis.
  34602. */
  34603. inertialPanningX: number;
  34604. /**
  34605. * Defines the current inertia value used during panning of the camera along the Y axis.
  34606. */
  34607. inertialPanningY: number;
  34608. /**
  34609. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  34610. * Basically if your fingers moves away from more than this distance you will be considered
  34611. * in pinch mode.
  34612. */
  34613. pinchToPanMaxDistance: number;
  34614. /**
  34615. * Defines the maximum distance the camera can pan.
  34616. * This could help keeping the cammera always in your scene.
  34617. */
  34618. panningDistanceLimit: Nullable<number>;
  34619. /**
  34620. * Defines the target of the camera before paning.
  34621. */
  34622. panningOriginTarget: Vector3;
  34623. /**
  34624. * Defines the value of the inertia used during panning.
  34625. * 0 would mean stop inertia and one would mean no decelleration at all.
  34626. */
  34627. panningInertia: number;
  34628. /**
  34629. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  34630. */
  34631. angularSensibilityX: number;
  34632. /**
  34633. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  34634. */
  34635. angularSensibilityY: number;
  34636. /**
  34637. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  34638. */
  34639. pinchPrecision: number;
  34640. /**
  34641. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  34642. * It will be used instead of pinchDeltaPrecision if different from 0.
  34643. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34644. */
  34645. pinchDeltaPercentage: number;
  34646. /**
  34647. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  34648. */
  34649. panningSensibility: number;
  34650. /**
  34651. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  34652. */
  34653. keysUp: number[];
  34654. /**
  34655. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  34656. */
  34657. keysDown: number[];
  34658. /**
  34659. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  34660. */
  34661. keysLeft: number[];
  34662. /**
  34663. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  34664. */
  34665. keysRight: number[];
  34666. /**
  34667. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  34668. */
  34669. wheelPrecision: number;
  34670. /**
  34671. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  34672. * It will be used instead of pinchDeltaPrecision if different from 0.
  34673. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  34674. */
  34675. wheelDeltaPercentage: number;
  34676. /**
  34677. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  34678. */
  34679. zoomOnFactor: number;
  34680. /**
  34681. * Defines a screen offset for the camera position.
  34682. */
  34683. targetScreenOffset: Vector2;
  34684. /**
  34685. * Allows the camera to be completely reversed.
  34686. * If false the camera can not arrive upside down.
  34687. */
  34688. allowUpsideDown: boolean;
  34689. /**
  34690. * Define if double tap/click is used to restore the previously saved state of the camera.
  34691. */
  34692. useInputToRestoreState: boolean;
  34693. /** @hidden */ private _viewMatrix: Matrix;
  34694. /** @hidden */ private _useCtrlForPanning: boolean;
  34695. /** @hidden */ private _panningMouseButton: number;
  34696. /**
  34697. * Defines the input associated to the camera.
  34698. */
  34699. inputs: ArcRotateCameraInputsManager;
  34700. /** @hidden */ private _reset: () => void;
  34701. /**
  34702. * Defines the allowed panning axis.
  34703. */
  34704. panningAxis: Vector3;
  34705. protected _localDirection: Vector3;
  34706. protected _transformedDirection: Vector3;
  34707. private _bouncingBehavior;
  34708. /**
  34709. * Gets the bouncing behavior of the camera if it has been enabled.
  34710. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34711. */
  34712. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  34713. /**
  34714. * Defines if the bouncing behavior of the camera is enabled on the camera.
  34715. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34716. */
  34717. useBouncingBehavior: boolean;
  34718. private _framingBehavior;
  34719. /**
  34720. * Gets the framing behavior of the camera if it has been enabled.
  34721. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34722. */
  34723. readonly framingBehavior: Nullable<FramingBehavior>;
  34724. /**
  34725. * Defines if the framing behavior of the camera is enabled on the camera.
  34726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34727. */
  34728. useFramingBehavior: boolean;
  34729. private _autoRotationBehavior;
  34730. /**
  34731. * Gets the auto rotation behavior of the camera if it has been enabled.
  34732. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34733. */
  34734. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  34735. /**
  34736. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  34737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34738. */
  34739. useAutoRotationBehavior: boolean;
  34740. /**
  34741. * Observable triggered when the mesh target has been changed on the camera.
  34742. */
  34743. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  34744. /**
  34745. * Event raised when the camera is colliding with a mesh.
  34746. */
  34747. onCollide: (collidedMesh: AbstractMesh) => void;
  34748. /**
  34749. * Defines whether the camera should check collision with the objects oh the scene.
  34750. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  34751. */
  34752. checkCollisions: boolean;
  34753. /**
  34754. * Defines the collision radius of the camera.
  34755. * This simulates a sphere around the camera.
  34756. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  34757. */
  34758. collisionRadius: Vector3;
  34759. protected _collider: Collider;
  34760. protected _previousPosition: Vector3;
  34761. protected _collisionVelocity: Vector3;
  34762. protected _newPosition: Vector3;
  34763. protected _previousAlpha: number;
  34764. protected _previousBeta: number;
  34765. protected _previousRadius: number;
  34766. protected _collisionTriggered: boolean;
  34767. protected _targetBoundingCenter: Nullable<Vector3>;
  34768. private _computationVector;
  34769. /**
  34770. * Instantiates a new ArcRotateCamera in a given scene
  34771. * @param name Defines the name of the camera
  34772. * @param alpha Defines the camera rotation along the logitudinal axis
  34773. * @param beta Defines the camera rotation along the latitudinal axis
  34774. * @param radius Defines the camera distance from its target
  34775. * @param target Defines the camera target
  34776. * @param scene Defines the scene the camera belongs to
  34777. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  34778. */
  34779. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  34780. /** @hidden */ private _initCache(): void;
  34781. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  34782. protected _getTargetPosition(): Vector3;
  34783. private _storedAlpha;
  34784. private _storedBeta;
  34785. private _storedRadius;
  34786. private _storedTarget;
  34787. /**
  34788. * Stores the current state of the camera (alpha, beta, radius and target)
  34789. * @returns the camera itself
  34790. */
  34791. storeState(): Camera;
  34792. /**
  34793. * @hidden
  34794. * Restored camera state. You must call storeState() first
  34795. */ private _restoreStateValues(): boolean;
  34796. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  34797. /**
  34798. * Attached controls to the current camera.
  34799. * @param element Defines the element the controls should be listened from
  34800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34801. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  34802. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  34803. */
  34804. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  34805. /**
  34806. * Detach the current controls from the camera.
  34807. * The camera will stop reacting to inputs.
  34808. * @param element Defines the element to stop listening the inputs from
  34809. */
  34810. detachControl(element: HTMLElement): void;
  34811. /** @hidden */ private _checkInputs(): void;
  34812. protected _checkLimits(): void;
  34813. /**
  34814. * Rebuilds angles (alpha, beta) and radius from the give position and target
  34815. */
  34816. rebuildAnglesAndRadius(): void;
  34817. /**
  34818. * Use a position to define the current camera related information like aplha, beta and radius
  34819. * @param position Defines the position to set the camera at
  34820. */
  34821. setPosition(position: Vector3): void;
  34822. /**
  34823. * Defines the target the camera should look at.
  34824. * This will automatically adapt alpha beta and radius to fit within the new target.
  34825. * @param target Defines the new target as a Vector or a mesh
  34826. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  34827. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  34828. */
  34829. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  34830. /** @hidden */ private _getViewMatrix(): Matrix;
  34831. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  34832. /**
  34833. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  34834. * @param meshes Defines the mesh to zoom on
  34835. * @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)
  34836. */
  34837. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  34838. /**
  34839. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  34840. * The target will be changed but the radius
  34841. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  34842. * @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)
  34843. */
  34844. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  34845. min: Vector3;
  34846. max: Vector3;
  34847. distance: number;
  34848. }, doNotUpdateMaxZ?: boolean): void;
  34849. /**
  34850. * @override
  34851. * Override Camera.createRigCamera
  34852. */
  34853. createRigCamera(name: string, cameraIndex: number): Camera;
  34854. /**
  34855. * @hidden
  34856. * @override
  34857. * Override Camera._updateRigCameras
  34858. */ private _updateRigCameras(): void;
  34859. /**
  34860. * Destroy the camera and release the current resources hold by it.
  34861. */
  34862. dispose(): void;
  34863. /**
  34864. * Gets the current object class name.
  34865. * @return the class name
  34866. */
  34867. getClassName(): string;
  34868. }
  34869. }
  34870. declare module BABYLON {
  34871. /**
  34872. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  34873. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  34874. */
  34875. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  34876. /**
  34877. * Gets the name of the behavior.
  34878. */
  34879. readonly name: string;
  34880. private _zoomStopsAnimation;
  34881. private _idleRotationSpeed;
  34882. private _idleRotationWaitTime;
  34883. private _idleRotationSpinupTime;
  34884. /**
  34885. * Sets the flag that indicates if user zooming should stop animation.
  34886. */
  34887. /**
  34888. * Gets the flag that indicates if user zooming should stop animation.
  34889. */
  34890. zoomStopsAnimation: boolean;
  34891. /**
  34892. * Sets the default speed at which the camera rotates around the model.
  34893. */
  34894. /**
  34895. * Gets the default speed at which the camera rotates around the model.
  34896. */
  34897. idleRotationSpeed: number;
  34898. /**
  34899. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  34900. */
  34901. /**
  34902. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  34903. */
  34904. idleRotationWaitTime: number;
  34905. /**
  34906. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34907. */
  34908. /**
  34909. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  34910. */
  34911. idleRotationSpinupTime: number;
  34912. /**
  34913. * Gets a value indicating if the camera is currently rotating because of this behavior
  34914. */
  34915. readonly rotationInProgress: boolean;
  34916. private _onPrePointerObservableObserver;
  34917. private _onAfterCheckInputsObserver;
  34918. private _attachedCamera;
  34919. private _isPointerDown;
  34920. private _lastFrameTime;
  34921. private _lastInteractionTime;
  34922. private _cameraRotationSpeed;
  34923. /**
  34924. * Initializes the behavior.
  34925. */
  34926. init(): void;
  34927. /**
  34928. * Attaches the behavior to its arc rotate camera.
  34929. * @param camera Defines the camera to attach the behavior to
  34930. */
  34931. attach(camera: ArcRotateCamera): void;
  34932. /**
  34933. * Detaches the behavior from its current arc rotate camera.
  34934. */
  34935. detach(): void;
  34936. /**
  34937. * Returns true if user is scrolling.
  34938. * @return true if user is scrolling.
  34939. */
  34940. private _userIsZooming;
  34941. private _lastFrameRadius;
  34942. private _shouldAnimationStopForInteraction;
  34943. /**
  34944. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34945. */
  34946. private _applyUserInteraction;
  34947. private _userIsMoving;
  34948. }
  34949. }
  34950. declare module BABYLON {
  34951. /**
  34952. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  34953. */
  34954. export class AttachToBoxBehavior implements Behavior<Mesh> {
  34955. private ui;
  34956. /**
  34957. * The name of the behavior
  34958. */
  34959. name: string;
  34960. /**
  34961. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  34962. */
  34963. distanceAwayFromFace: number;
  34964. /**
  34965. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  34966. */
  34967. distanceAwayFromBottomOfFace: number;
  34968. private _faceVectors;
  34969. private _target;
  34970. private _scene;
  34971. private _onRenderObserver;
  34972. private _tmpMatrix;
  34973. private _tmpVector;
  34974. /**
  34975. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  34976. * @param ui The transform node that should be attched to the mesh
  34977. */
  34978. constructor(ui: TransformNode);
  34979. /**
  34980. * Initializes the behavior
  34981. */
  34982. init(): void;
  34983. private _closestFace;
  34984. private _zeroVector;
  34985. private _lookAtTmpMatrix;
  34986. private _lookAtToRef;
  34987. /**
  34988. * Attaches the AttachToBoxBehavior to the passed in mesh
  34989. * @param target The mesh that the specified node will be attached to
  34990. */
  34991. attach(target: Mesh): void;
  34992. /**
  34993. * Detaches the behavior from the mesh
  34994. */
  34995. detach(): void;
  34996. }
  34997. }
  34998. declare module BABYLON {
  34999. /**
  35000. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35001. */
  35002. export class FadeInOutBehavior implements Behavior<Mesh> {
  35003. /**
  35004. * Time in milliseconds to delay before fading in (Default: 0)
  35005. */
  35006. delay: number;
  35007. /**
  35008. * Time in milliseconds for the mesh to fade in (Default: 300)
  35009. */
  35010. fadeInTime: number;
  35011. private _millisecondsPerFrame;
  35012. private _hovered;
  35013. private _hoverValue;
  35014. private _ownerNode;
  35015. /**
  35016. * Instatiates the FadeInOutBehavior
  35017. */
  35018. constructor();
  35019. /**
  35020. * The name of the behavior
  35021. */
  35022. readonly name: string;
  35023. /**
  35024. * Initializes the behavior
  35025. */
  35026. init(): void;
  35027. /**
  35028. * Attaches the fade behavior on the passed in mesh
  35029. * @param ownerNode The mesh that will be faded in/out once attached
  35030. */
  35031. attach(ownerNode: Mesh): void;
  35032. /**
  35033. * Detaches the behavior from the mesh
  35034. */
  35035. detach(): void;
  35036. /**
  35037. * Triggers the mesh to begin fading in or out
  35038. * @param value if the object should fade in or out (true to fade in)
  35039. */
  35040. fadeIn(value: boolean): void;
  35041. private _update;
  35042. private _setAllVisibility;
  35043. }
  35044. }
  35045. declare module BABYLON {
  35046. /**
  35047. * Class containing a set of static utilities functions for managing Pivots
  35048. * @hidden
  35049. */
  35050. export class PivotTools {
  35051. private static _PivotCached;
  35052. private static _OldPivotPoint;
  35053. private static _PivotTranslation;
  35054. private static _PivotTmpVector;
  35055. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35056. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35057. }
  35058. }
  35059. declare module BABYLON {
  35060. /**
  35061. * Class containing static functions to help procedurally build meshes
  35062. */
  35063. export class PlaneBuilder {
  35064. /**
  35065. * Creates a plane mesh
  35066. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35067. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35068. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35069. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35070. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  35071. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35072. * @param name defines the name of the mesh
  35073. * @param options defines the options used to create the mesh
  35074. * @param scene defines the hosting scene
  35075. * @returns the plane mesh
  35076. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35077. */
  35078. static CreatePlane(name: string, options: {
  35079. size?: number;
  35080. width?: number;
  35081. height?: number;
  35082. sideOrientation?: number;
  35083. frontUVs?: Vector4;
  35084. backUVs?: Vector4;
  35085. updatable?: boolean;
  35086. sourcePlane?: Plane;
  35087. }, scene?: Nullable<Scene>): Mesh;
  35088. }
  35089. }
  35090. declare module BABYLON {
  35091. /**
  35092. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35093. */
  35094. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35095. private static _AnyMouseID;
  35096. /**
  35097. * Abstract mesh the behavior is set on
  35098. */
  35099. attachedNode: AbstractMesh;
  35100. private _dragPlane;
  35101. private _scene;
  35102. private _pointerObserver;
  35103. private _beforeRenderObserver;
  35104. private static _planeScene;
  35105. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35106. /**
  35107. * 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)
  35108. */
  35109. maxDragAngle: number;
  35110. /**
  35111. * @hidden
  35112. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35113. /**
  35114. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35115. */
  35116. currentDraggingPointerID: number;
  35117. /**
  35118. * The last position where the pointer hit the drag plane in world space
  35119. */
  35120. lastDragPosition: Vector3;
  35121. /**
  35122. * If the behavior is currently in a dragging state
  35123. */
  35124. dragging: boolean;
  35125. /**
  35126. * 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)
  35127. */
  35128. dragDeltaRatio: number;
  35129. /**
  35130. * If the drag plane orientation should be updated during the dragging (Default: true)
  35131. */
  35132. updateDragPlane: boolean;
  35133. private _debugMode;
  35134. private _moving;
  35135. /**
  35136. * Fires each time the attached mesh is dragged with the pointer
  35137. * * delta between last drag position and current drag position in world space
  35138. * * dragDistance along the drag axis
  35139. * * dragPlaneNormal normal of the current drag plane used during the drag
  35140. * * dragPlanePoint in world space where the drag intersects the drag plane
  35141. */
  35142. onDragObservable: Observable<{
  35143. delta: Vector3;
  35144. dragPlanePoint: Vector3;
  35145. dragPlaneNormal: Vector3;
  35146. dragDistance: number;
  35147. pointerId: number;
  35148. }>;
  35149. /**
  35150. * Fires each time a drag begins (eg. mouse down on mesh)
  35151. */
  35152. onDragStartObservable: Observable<{
  35153. dragPlanePoint: Vector3;
  35154. pointerId: number;
  35155. }>;
  35156. /**
  35157. * Fires each time a drag ends (eg. mouse release after drag)
  35158. */
  35159. onDragEndObservable: Observable<{
  35160. dragPlanePoint: Vector3;
  35161. pointerId: number;
  35162. }>;
  35163. /**
  35164. * If the attached mesh should be moved when dragged
  35165. */
  35166. moveAttached: boolean;
  35167. /**
  35168. * If the drag behavior will react to drag events (Default: true)
  35169. */
  35170. enabled: boolean;
  35171. /**
  35172. * If camera controls should be detached during the drag
  35173. */
  35174. detachCameraControls: boolean;
  35175. /**
  35176. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35177. */
  35178. useObjectOrienationForDragging: boolean;
  35179. private _options;
  35180. /**
  35181. * Creates a pointer drag behavior that can be attached to a mesh
  35182. * @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)
  35183. */
  35184. constructor(options?: {
  35185. dragAxis?: Vector3;
  35186. dragPlaneNormal?: Vector3;
  35187. });
  35188. /**
  35189. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35190. */
  35191. validateDrag: (targetPosition: Vector3) => boolean;
  35192. /**
  35193. * The name of the behavior
  35194. */
  35195. readonly name: string;
  35196. /**
  35197. * Initializes the behavior
  35198. */
  35199. init(): void;
  35200. private _tmpVector;
  35201. private _alternatePickedPoint;
  35202. private _worldDragAxis;
  35203. private _targetPosition;
  35204. private _attachedElement;
  35205. /**
  35206. * Attaches the drag behavior the passed in mesh
  35207. * @param ownerNode The mesh that will be dragged around once attached
  35208. */
  35209. attach(ownerNode: AbstractMesh): void;
  35210. /**
  35211. * Force relase the drag action by code.
  35212. */
  35213. releaseDrag(): void;
  35214. private _startDragRay;
  35215. private _lastPointerRay;
  35216. /**
  35217. * Simulates the start of a pointer drag event on the behavior
  35218. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35219. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35220. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35221. */
  35222. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35223. private _startDrag;
  35224. private _dragDelta;
  35225. private _moveDrag;
  35226. private _pickWithRayOnDragPlane;
  35227. private _pointA;
  35228. private _pointB;
  35229. private _pointC;
  35230. private _lineA;
  35231. private _lineB;
  35232. private _localAxis;
  35233. private _lookAt;
  35234. private _updateDragPlanePosition;
  35235. /**
  35236. * Detaches the behavior from the mesh
  35237. */
  35238. detach(): void;
  35239. }
  35240. }
  35241. declare module BABYLON {
  35242. /**
  35243. * A behavior that when attached to a mesh will allow the mesh to be scaled
  35244. */
  35245. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  35246. private _dragBehaviorA;
  35247. private _dragBehaviorB;
  35248. private _startDistance;
  35249. private _initialScale;
  35250. private _targetScale;
  35251. private _ownerNode;
  35252. private _sceneRenderObserver;
  35253. /**
  35254. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  35255. */
  35256. constructor();
  35257. /**
  35258. * The name of the behavior
  35259. */
  35260. readonly name: string;
  35261. /**
  35262. * Initializes the behavior
  35263. */
  35264. init(): void;
  35265. private _getCurrentDistance;
  35266. /**
  35267. * Attaches the scale behavior the passed in mesh
  35268. * @param ownerNode The mesh that will be scaled around once attached
  35269. */
  35270. attach(ownerNode: Mesh): void;
  35271. /**
  35272. * Detaches the behavior from the mesh
  35273. */
  35274. detach(): void;
  35275. }
  35276. }
  35277. declare module BABYLON {
  35278. /**
  35279. * 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
  35280. */
  35281. export class SixDofDragBehavior implements Behavior<Mesh> {
  35282. private static _virtualScene;
  35283. private _ownerNode;
  35284. private _sceneRenderObserver;
  35285. private _scene;
  35286. private _targetPosition;
  35287. private _virtualOriginMesh;
  35288. private _virtualDragMesh;
  35289. private _pointerObserver;
  35290. private _moving;
  35291. private _startingOrientation;
  35292. /**
  35293. * 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)
  35294. */
  35295. private zDragFactor;
  35296. /**
  35297. * If the object should rotate to face the drag origin
  35298. */
  35299. rotateDraggedObject: boolean;
  35300. /**
  35301. * If the behavior is currently in a dragging state
  35302. */
  35303. dragging: boolean;
  35304. /**
  35305. * 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)
  35306. */
  35307. dragDeltaRatio: number;
  35308. /**
  35309. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35310. */
  35311. currentDraggingPointerID: number;
  35312. /**
  35313. * If camera controls should be detached during the drag
  35314. */
  35315. detachCameraControls: boolean;
  35316. /**
  35317. * Fires each time a drag starts
  35318. */
  35319. onDragStartObservable: Observable<{}>;
  35320. /**
  35321. * Fires each time a drag ends (eg. mouse release after drag)
  35322. */
  35323. onDragEndObservable: Observable<{}>;
  35324. /**
  35325. * 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
  35326. */
  35327. constructor();
  35328. /**
  35329. * The name of the behavior
  35330. */
  35331. readonly name: string;
  35332. /**
  35333. * Initializes the behavior
  35334. */
  35335. init(): void;
  35336. /**
  35337. * Attaches the scale behavior the passed in mesh
  35338. * @param ownerNode The mesh that will be scaled around once attached
  35339. */
  35340. attach(ownerNode: Mesh): void;
  35341. /**
  35342. * Detaches the behavior from the mesh
  35343. */
  35344. detach(): void;
  35345. }
  35346. }
  35347. declare module BABYLON {
  35348. /**
  35349. * Class used to apply inverse kinematics to bones
  35350. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  35351. */
  35352. export class BoneIKController {
  35353. private static _tmpVecs;
  35354. private static _tmpQuat;
  35355. private static _tmpMats;
  35356. /**
  35357. * Gets or sets the target mesh
  35358. */
  35359. targetMesh: AbstractMesh;
  35360. /** Gets or sets the mesh used as pole */
  35361. poleTargetMesh: AbstractMesh;
  35362. /**
  35363. * Gets or sets the bone used as pole
  35364. */
  35365. poleTargetBone: Nullable<Bone>;
  35366. /**
  35367. * Gets or sets the target position
  35368. */
  35369. targetPosition: Vector3;
  35370. /**
  35371. * Gets or sets the pole target position
  35372. */
  35373. poleTargetPosition: Vector3;
  35374. /**
  35375. * Gets or sets the pole target local offset
  35376. */
  35377. poleTargetLocalOffset: Vector3;
  35378. /**
  35379. * Gets or sets the pole angle
  35380. */
  35381. poleAngle: number;
  35382. /**
  35383. * Gets or sets the mesh associated with the controller
  35384. */
  35385. mesh: AbstractMesh;
  35386. /**
  35387. * 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)
  35388. */
  35389. slerpAmount: number;
  35390. private _bone1Quat;
  35391. private _bone1Mat;
  35392. private _bone2Ang;
  35393. private _bone1;
  35394. private _bone2;
  35395. private _bone1Length;
  35396. private _bone2Length;
  35397. private _maxAngle;
  35398. private _maxReach;
  35399. private _rightHandedSystem;
  35400. private _bendAxis;
  35401. private _slerping;
  35402. private _adjustRoll;
  35403. /**
  35404. * Gets or sets maximum allowed angle
  35405. */
  35406. maxAngle: number;
  35407. /**
  35408. * Creates a new BoneIKController
  35409. * @param mesh defines the mesh to control
  35410. * @param bone defines the bone to control
  35411. * @param options defines options to set up the controller
  35412. */
  35413. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  35414. targetMesh?: AbstractMesh;
  35415. poleTargetMesh?: AbstractMesh;
  35416. poleTargetBone?: Bone;
  35417. poleTargetLocalOffset?: Vector3;
  35418. poleAngle?: number;
  35419. bendAxis?: Vector3;
  35420. maxAngle?: number;
  35421. slerpAmount?: number;
  35422. });
  35423. private _setMaxAngle;
  35424. /**
  35425. * Force the controller to update the bones
  35426. */
  35427. update(): void;
  35428. }
  35429. }
  35430. declare module BABYLON {
  35431. /**
  35432. * Class used to make a bone look toward a point in space
  35433. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  35434. */
  35435. export class BoneLookController {
  35436. private static _tmpVecs;
  35437. private static _tmpQuat;
  35438. private static _tmpMats;
  35439. /**
  35440. * The target Vector3 that the bone will look at
  35441. */
  35442. target: Vector3;
  35443. /**
  35444. * The mesh that the bone is attached to
  35445. */
  35446. mesh: AbstractMesh;
  35447. /**
  35448. * The bone that will be looking to the target
  35449. */
  35450. bone: Bone;
  35451. /**
  35452. * The up axis of the coordinate system that is used when the bone is rotated
  35453. */
  35454. upAxis: Vector3;
  35455. /**
  35456. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  35457. */
  35458. upAxisSpace: Space;
  35459. /**
  35460. * Used to make an adjustment to the yaw of the bone
  35461. */
  35462. adjustYaw: number;
  35463. /**
  35464. * Used to make an adjustment to the pitch of the bone
  35465. */
  35466. adjustPitch: number;
  35467. /**
  35468. * Used to make an adjustment to the roll of the bone
  35469. */
  35470. adjustRoll: number;
  35471. /**
  35472. * 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)
  35473. */
  35474. slerpAmount: number;
  35475. private _minYaw;
  35476. private _maxYaw;
  35477. private _minPitch;
  35478. private _maxPitch;
  35479. private _minYawSin;
  35480. private _minYawCos;
  35481. private _maxYawSin;
  35482. private _maxYawCos;
  35483. private _midYawConstraint;
  35484. private _minPitchTan;
  35485. private _maxPitchTan;
  35486. private _boneQuat;
  35487. private _slerping;
  35488. private _transformYawPitch;
  35489. private _transformYawPitchInv;
  35490. private _firstFrameSkipped;
  35491. private _yawRange;
  35492. private _fowardAxis;
  35493. /**
  35494. * Gets or sets the minimum yaw angle that the bone can look to
  35495. */
  35496. minYaw: number;
  35497. /**
  35498. * Gets or sets the maximum yaw angle that the bone can look to
  35499. */
  35500. maxYaw: number;
  35501. /**
  35502. * Gets or sets the minimum pitch angle that the bone can look to
  35503. */
  35504. minPitch: number;
  35505. /**
  35506. * Gets or sets the maximum pitch angle that the bone can look to
  35507. */
  35508. maxPitch: number;
  35509. /**
  35510. * Create a BoneLookController
  35511. * @param mesh the mesh that the bone belongs to
  35512. * @param bone the bone that will be looking to the target
  35513. * @param target the target Vector3 to look at
  35514. * @param options optional settings:
  35515. * * maxYaw: the maximum angle the bone will yaw to
  35516. * * minYaw: the minimum angle the bone will yaw to
  35517. * * maxPitch: the maximum angle the bone will pitch to
  35518. * * minPitch: the minimum angle the bone will yaw to
  35519. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  35520. * * upAxis: the up axis of the coordinate system
  35521. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  35522. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  35523. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  35524. * * adjustYaw: used to make an adjustment to the yaw of the bone
  35525. * * adjustPitch: used to make an adjustment to the pitch of the bone
  35526. * * adjustRoll: used to make an adjustment to the roll of the bone
  35527. **/
  35528. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  35529. maxYaw?: number;
  35530. minYaw?: number;
  35531. maxPitch?: number;
  35532. minPitch?: number;
  35533. slerpAmount?: number;
  35534. upAxis?: Vector3;
  35535. upAxisSpace?: Space;
  35536. yawAxis?: Vector3;
  35537. pitchAxis?: Vector3;
  35538. adjustYaw?: number;
  35539. adjustPitch?: number;
  35540. adjustRoll?: number;
  35541. });
  35542. /**
  35543. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  35544. */
  35545. update(): void;
  35546. private _getAngleDiff;
  35547. private _getAngleBetween;
  35548. private _isAngleBetween;
  35549. }
  35550. }
  35551. declare module BABYLON {
  35552. /**
  35553. * Manage the gamepad inputs to control an arc rotate camera.
  35554. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35555. */
  35556. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  35557. /**
  35558. * Defines the camera the input is attached to.
  35559. */
  35560. camera: ArcRotateCamera;
  35561. /**
  35562. * Defines the gamepad the input is gathering event from.
  35563. */
  35564. gamepad: Nullable<Gamepad>;
  35565. /**
  35566. * Defines the gamepad rotation sensiblity.
  35567. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  35568. */
  35569. gamepadRotationSensibility: number;
  35570. /**
  35571. * Defines the gamepad move sensiblity.
  35572. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  35573. */
  35574. gamepadMoveSensibility: number;
  35575. private _onGamepadConnectedObserver;
  35576. private _onGamepadDisconnectedObserver;
  35577. /**
  35578. * Attach the input controls to a specific dom element to get the input from.
  35579. * @param element Defines the element the controls should be listened from
  35580. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35581. */
  35582. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35583. /**
  35584. * Detach the current controls from the specified dom element.
  35585. * @param element Defines the element to stop listening the inputs from
  35586. */
  35587. detachControl(element: Nullable<HTMLElement>): void;
  35588. /**
  35589. * Update the current camera state depending on the inputs that have been used this frame.
  35590. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35591. */
  35592. checkInputs(): void;
  35593. /**
  35594. * Gets the class name of the current intput.
  35595. * @returns the class name
  35596. */
  35597. getClassName(): string;
  35598. /**
  35599. * Get the friendly name associated with the input class.
  35600. * @returns the input friendly name
  35601. */
  35602. getSimpleName(): string;
  35603. }
  35604. }
  35605. declare module BABYLON {
  35606. interface ArcRotateCameraInputsManager {
  35607. /**
  35608. * Add orientation input support to the input manager.
  35609. * @returns the current input manager
  35610. */
  35611. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  35612. }
  35613. /**
  35614. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  35615. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35616. */
  35617. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  35618. /**
  35619. * Defines the camera the input is attached to.
  35620. */
  35621. camera: ArcRotateCamera;
  35622. /**
  35623. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  35624. */
  35625. alphaCorrection: number;
  35626. /**
  35627. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  35628. */
  35629. gammaCorrection: number;
  35630. private _alpha;
  35631. private _gamma;
  35632. private _dirty;
  35633. private _deviceOrientationHandler;
  35634. /**
  35635. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  35636. */
  35637. constructor();
  35638. /**
  35639. * Attach the input controls to a specific dom element to get the input from.
  35640. * @param element Defines the element the controls should be listened from
  35641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35642. */
  35643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35644. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  35645. /**
  35646. * Update the current camera state depending on the inputs that have been used this frame.
  35647. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35648. */
  35649. checkInputs(): void;
  35650. /**
  35651. * Detach the current controls from the specified dom element.
  35652. * @param element Defines the element to stop listening the inputs from
  35653. */
  35654. detachControl(element: Nullable<HTMLElement>): void;
  35655. /**
  35656. * Gets the class name of the current intput.
  35657. * @returns the class name
  35658. */
  35659. getClassName(): string;
  35660. /**
  35661. * Get the friendly name associated with the input class.
  35662. * @returns the input friendly name
  35663. */
  35664. getSimpleName(): string;
  35665. }
  35666. }
  35667. declare module BABYLON {
  35668. /**
  35669. * Listen to mouse events to control the camera.
  35670. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35671. */
  35672. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  35673. /**
  35674. * Defines the camera the input is attached to.
  35675. */
  35676. camera: FlyCamera;
  35677. /**
  35678. * Defines if touch is enabled. (Default is true.)
  35679. */
  35680. touchEnabled: boolean;
  35681. /**
  35682. * Defines the buttons associated with the input to handle camera rotation.
  35683. */
  35684. buttons: number[];
  35685. /**
  35686. * Assign buttons for Yaw control.
  35687. */
  35688. buttonsYaw: number[];
  35689. /**
  35690. * Assign buttons for Pitch control.
  35691. */
  35692. buttonsPitch: number[];
  35693. /**
  35694. * Assign buttons for Roll control.
  35695. */
  35696. buttonsRoll: number[];
  35697. /**
  35698. * Detect if any button is being pressed while mouse is moved.
  35699. * -1 = Mouse locked.
  35700. * 0 = Left button.
  35701. * 1 = Middle Button.
  35702. * 2 = Right Button.
  35703. */
  35704. activeButton: number;
  35705. /**
  35706. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  35707. * Higher values reduce its sensitivity.
  35708. */
  35709. angularSensibility: number;
  35710. private _mousemoveCallback;
  35711. private _observer;
  35712. private _rollObserver;
  35713. private previousPosition;
  35714. private noPreventDefault;
  35715. private element;
  35716. /**
  35717. * Listen to mouse events to control the camera.
  35718. * @param touchEnabled Define if touch is enabled. (Default is true.)
  35719. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35720. */
  35721. constructor(touchEnabled?: boolean);
  35722. /**
  35723. * Attach the mouse control to the HTML DOM element.
  35724. * @param element Defines the element that listens to the input events.
  35725. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  35726. */
  35727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35728. /**
  35729. * Detach the current controls from the specified dom element.
  35730. * @param element Defines the element to stop listening the inputs from
  35731. */
  35732. detachControl(element: Nullable<HTMLElement>): void;
  35733. /**
  35734. * Gets the class name of the current input.
  35735. * @returns the class name.
  35736. */
  35737. getClassName(): string;
  35738. /**
  35739. * Get the friendly name associated with the input class.
  35740. * @returns the input's friendly name.
  35741. */
  35742. getSimpleName(): string;
  35743. private _pointerInput;
  35744. private _onMouseMove;
  35745. /**
  35746. * Rotate camera by mouse offset.
  35747. */
  35748. private rotateCamera;
  35749. }
  35750. }
  35751. declare module BABYLON {
  35752. /**
  35753. * Default Inputs manager for the FlyCamera.
  35754. * It groups all the default supported inputs for ease of use.
  35755. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35756. */
  35757. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  35758. /**
  35759. * Instantiates a new FlyCameraInputsManager.
  35760. * @param camera Defines the camera the inputs belong to.
  35761. */
  35762. constructor(camera: FlyCamera);
  35763. /**
  35764. * Add keyboard input support to the input manager.
  35765. * @returns the new FlyCameraKeyboardMoveInput().
  35766. */
  35767. addKeyboard(): FlyCameraInputsManager;
  35768. /**
  35769. * Add mouse input support to the input manager.
  35770. * @param touchEnabled Enable touch screen support.
  35771. * @returns the new FlyCameraMouseInput().
  35772. */
  35773. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  35774. }
  35775. }
  35776. declare module BABYLON {
  35777. /**
  35778. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35779. * such as in a 3D Space Shooter or a Flight Simulator.
  35780. */
  35781. export class FlyCamera extends TargetCamera {
  35782. /**
  35783. * Define the collision ellipsoid of the camera.
  35784. * This is helpful for simulating a camera body, like a player's body.
  35785. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35786. */
  35787. ellipsoid: Vector3;
  35788. /**
  35789. * Define an offset for the position of the ellipsoid around the camera.
  35790. * This can be helpful if the camera is attached away from the player's body center,
  35791. * such as at its head.
  35792. */
  35793. ellipsoidOffset: Vector3;
  35794. /**
  35795. * Enable or disable collisions of the camera with the rest of the scene objects.
  35796. */
  35797. checkCollisions: boolean;
  35798. /**
  35799. * Enable or disable gravity on the camera.
  35800. */
  35801. applyGravity: boolean;
  35802. /**
  35803. * Define the current direction the camera is moving to.
  35804. */
  35805. cameraDirection: Vector3;
  35806. /**
  35807. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  35808. * This overrides and empties cameraRotation.
  35809. */
  35810. rotationQuaternion: Quaternion;
  35811. /**
  35812. * Track Roll to maintain the wanted Rolling when looking around.
  35813. */ private _trackRoll: number;
  35814. /**
  35815. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  35816. */
  35817. rollCorrect: number;
  35818. /**
  35819. * Mimic a banked turn, Rolling the camera when Yawing.
  35820. * It's recommended to use rollCorrect = 10 for faster banking correction.
  35821. */
  35822. bankedTurn: boolean;
  35823. /**
  35824. * Limit in radians for how much Roll banking will add. (Default: 90°)
  35825. */
  35826. bankedTurnLimit: number;
  35827. /**
  35828. * Value of 0 disables the banked Roll.
  35829. * Value of 1 is equal to the Yaw angle in radians.
  35830. */
  35831. bankedTurnMultiplier: number;
  35832. /**
  35833. * The inputs manager loads all the input sources, such as keyboard and mouse.
  35834. */
  35835. inputs: FlyCameraInputsManager;
  35836. /**
  35837. * Gets the input sensibility for mouse input.
  35838. * Higher values reduce sensitivity.
  35839. */
  35840. /**
  35841. * Sets the input sensibility for a mouse input.
  35842. * Higher values reduce sensitivity.
  35843. */
  35844. angularSensibility: number;
  35845. /**
  35846. * Get the keys for camera movement forward.
  35847. */
  35848. /**
  35849. * Set the keys for camera movement forward.
  35850. */
  35851. keysForward: number[];
  35852. /**
  35853. * Get the keys for camera movement backward.
  35854. */
  35855. keysBackward: number[];
  35856. /**
  35857. * Get the keys for camera movement up.
  35858. */
  35859. /**
  35860. * Set the keys for camera movement up.
  35861. */
  35862. keysUp: number[];
  35863. /**
  35864. * Get the keys for camera movement down.
  35865. */
  35866. /**
  35867. * Set the keys for camera movement down.
  35868. */
  35869. keysDown: number[];
  35870. /**
  35871. * Get the keys for camera movement left.
  35872. */
  35873. /**
  35874. * Set the keys for camera movement left.
  35875. */
  35876. keysLeft: number[];
  35877. /**
  35878. * Set the keys for camera movement right.
  35879. */
  35880. /**
  35881. * Set the keys for camera movement right.
  35882. */
  35883. keysRight: number[];
  35884. /**
  35885. * Event raised when the camera collides with a mesh in the scene.
  35886. */
  35887. onCollide: (collidedMesh: AbstractMesh) => void;
  35888. private _collider;
  35889. private _needMoveForGravity;
  35890. private _oldPosition;
  35891. private _diffPosition;
  35892. private _newPosition;
  35893. /** @hidden */ private _localDirection: Vector3;
  35894. /** @hidden */ private _transformedDirection: Vector3;
  35895. /**
  35896. * Instantiates a FlyCamera.
  35897. * This is a flying camera, designed for 3D movement and rotation in all directions,
  35898. * such as in a 3D Space Shooter or a Flight Simulator.
  35899. * @param name Define the name of the camera in the scene.
  35900. * @param position Define the starting position of the camera in the scene.
  35901. * @param scene Define the scene the camera belongs to.
  35902. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  35903. */
  35904. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35905. /**
  35906. * Attach a control to the HTML DOM element.
  35907. * @param element Defines the element that listens to the input events.
  35908. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  35909. */
  35910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35911. /**
  35912. * Detach a control from the HTML DOM element.
  35913. * The camera will stop reacting to that input.
  35914. * @param element Defines the element that listens to the input events.
  35915. */
  35916. detachControl(element: HTMLElement): void;
  35917. private _collisionMask;
  35918. /**
  35919. * Get the mask that the camera ignores in collision events.
  35920. */
  35921. /**
  35922. * Set the mask that the camera ignores in collision events.
  35923. */
  35924. collisionMask: number;
  35925. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  35926. /** @hidden */
  35927. private _onCollisionPositionChange;
  35928. /** @hidden */ private _checkInputs(): void;
  35929. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  35930. /** @hidden */ private _updatePosition(): void;
  35931. /**
  35932. * Restore the Roll to its target value at the rate specified.
  35933. * @param rate - Higher means slower restoring.
  35934. * @hidden
  35935. */
  35936. restoreRoll(rate: number): void;
  35937. /**
  35938. * Destroy the camera and release the current resources held by it.
  35939. */
  35940. dispose(): void;
  35941. /**
  35942. * Get the current object class name.
  35943. * @returns the class name.
  35944. */
  35945. getClassName(): string;
  35946. }
  35947. }
  35948. declare module BABYLON {
  35949. /**
  35950. * Listen to keyboard events to control the camera.
  35951. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35952. */
  35953. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  35954. /**
  35955. * Defines the camera the input is attached to.
  35956. */
  35957. camera: FlyCamera;
  35958. /**
  35959. * The list of keyboard keys used to control the forward move of the camera.
  35960. */
  35961. keysForward: number[];
  35962. /**
  35963. * The list of keyboard keys used to control the backward move of the camera.
  35964. */
  35965. keysBackward: number[];
  35966. /**
  35967. * The list of keyboard keys used to control the forward move of the camera.
  35968. */
  35969. keysUp: number[];
  35970. /**
  35971. * The list of keyboard keys used to control the backward move of the camera.
  35972. */
  35973. keysDown: number[];
  35974. /**
  35975. * The list of keyboard keys used to control the right strafe move of the camera.
  35976. */
  35977. keysRight: number[];
  35978. /**
  35979. * The list of keyboard keys used to control the left strafe move of the camera.
  35980. */
  35981. keysLeft: number[];
  35982. private _keys;
  35983. private _onCanvasBlurObserver;
  35984. private _onKeyboardObserver;
  35985. private _engine;
  35986. private _scene;
  35987. /**
  35988. * Attach the input controls to a specific dom element to get the input from.
  35989. * @param element Defines the element the controls should be listened from
  35990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35991. */
  35992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35993. /**
  35994. * Detach the current controls from the specified dom element.
  35995. * @param element Defines the element to stop listening the inputs from
  35996. */
  35997. detachControl(element: Nullable<HTMLElement>): void;
  35998. /**
  35999. * Gets the class name of the current intput.
  36000. * @returns the class name
  36001. */
  36002. getClassName(): string;
  36003. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36004. /**
  36005. * Get the friendly name associated with the input class.
  36006. * @returns the input friendly name
  36007. */
  36008. getSimpleName(): string;
  36009. /**
  36010. * Update the current camera state depending on the inputs that have been used this frame.
  36011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36012. */
  36013. checkInputs(): void;
  36014. }
  36015. }
  36016. declare module BABYLON {
  36017. /**
  36018. * Manage the mouse wheel inputs to control a follow camera.
  36019. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36020. */
  36021. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36022. /**
  36023. * Defines the camera the input is attached to.
  36024. */
  36025. camera: FollowCamera;
  36026. /**
  36027. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36028. */
  36029. axisControlRadius: boolean;
  36030. /**
  36031. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36032. */
  36033. axisControlHeight: boolean;
  36034. /**
  36035. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36036. */
  36037. axisControlRotation: boolean;
  36038. /**
  36039. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36040. * relation to mouseWheel events.
  36041. */
  36042. wheelPrecision: number;
  36043. /**
  36044. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36045. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36046. */
  36047. wheelDeltaPercentage: number;
  36048. private _wheel;
  36049. private _observer;
  36050. /**
  36051. * Attach the input controls to a specific dom element to get the input from.
  36052. * @param element Defines the element the controls should be listened from
  36053. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36054. */
  36055. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36056. /**
  36057. * Detach the current controls from the specified dom element.
  36058. * @param element Defines the element to stop listening the inputs from
  36059. */
  36060. detachControl(element: Nullable<HTMLElement>): void;
  36061. /**
  36062. * Gets the class name of the current intput.
  36063. * @returns the class name
  36064. */
  36065. getClassName(): string;
  36066. /**
  36067. * Get the friendly name associated with the input class.
  36068. * @returns the input friendly name
  36069. */
  36070. getSimpleName(): string;
  36071. }
  36072. }
  36073. declare module BABYLON {
  36074. /**
  36075. * Manage the pointers inputs to control an follow camera.
  36076. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36077. */
  36078. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36079. /**
  36080. * Defines the camera the input is attached to.
  36081. */
  36082. camera: FollowCamera;
  36083. /**
  36084. * Gets the class name of the current input.
  36085. * @returns the class name
  36086. */
  36087. getClassName(): string;
  36088. /**
  36089. * Defines the pointer angular sensibility along the X axis or how fast is
  36090. * the camera rotating.
  36091. * A negative number will reverse the axis direction.
  36092. */
  36093. angularSensibilityX: number;
  36094. /**
  36095. * Defines the pointer angular sensibility along the Y axis or how fast is
  36096. * the camera rotating.
  36097. * A negative number will reverse the axis direction.
  36098. */
  36099. angularSensibilityY: number;
  36100. /**
  36101. * Defines the pointer pinch precision or how fast is the camera zooming.
  36102. * A negative number will reverse the axis direction.
  36103. */
  36104. pinchPrecision: number;
  36105. /**
  36106. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36107. * from 0.
  36108. * It defines the percentage of current camera.radius to use as delta when
  36109. * pinch zoom is used.
  36110. */
  36111. pinchDeltaPercentage: number;
  36112. /**
  36113. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36114. */
  36115. axisXControlRadius: boolean;
  36116. /**
  36117. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36118. */
  36119. axisXControlHeight: boolean;
  36120. /**
  36121. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36122. */
  36123. axisXControlRotation: boolean;
  36124. /**
  36125. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36126. */
  36127. axisYControlRadius: boolean;
  36128. /**
  36129. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36130. */
  36131. axisYControlHeight: boolean;
  36132. /**
  36133. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36134. */
  36135. axisYControlRotation: boolean;
  36136. /**
  36137. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36138. */
  36139. axisPinchControlRadius: boolean;
  36140. /**
  36141. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36142. */
  36143. axisPinchControlHeight: boolean;
  36144. /**
  36145. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36146. */
  36147. axisPinchControlRotation: boolean;
  36148. /**
  36149. * Log error messages if basic misconfiguration has occurred.
  36150. */
  36151. warningEnable: boolean;
  36152. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36153. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36154. private _warningCounter;
  36155. private _warning;
  36156. }
  36157. }
  36158. declare module BABYLON {
  36159. /**
  36160. * Default Inputs manager for the FollowCamera.
  36161. * It groups all the default supported inputs for ease of use.
  36162. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36163. */
  36164. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36165. /**
  36166. * Instantiates a new FollowCameraInputsManager.
  36167. * @param camera Defines the camera the inputs belong to
  36168. */
  36169. constructor(camera: FollowCamera);
  36170. /**
  36171. * Add keyboard input support to the input manager.
  36172. * @returns the current input manager
  36173. */
  36174. addKeyboard(): FollowCameraInputsManager;
  36175. /**
  36176. * Add mouse wheel input support to the input manager.
  36177. * @returns the current input manager
  36178. */
  36179. addMouseWheel(): FollowCameraInputsManager;
  36180. /**
  36181. * Add pointers input support to the input manager.
  36182. * @returns the current input manager
  36183. */
  36184. addPointers(): FollowCameraInputsManager;
  36185. /**
  36186. * Add orientation input support to the input manager.
  36187. * @returns the current input manager
  36188. */
  36189. addVRDeviceOrientation(): FollowCameraInputsManager;
  36190. }
  36191. }
  36192. declare module BABYLON {
  36193. /**
  36194. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36195. * an arc rotate version arcFollowCamera are available.
  36196. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36197. */
  36198. export class FollowCamera extends TargetCamera {
  36199. /**
  36200. * Distance the follow camera should follow an object at
  36201. */
  36202. radius: number;
  36203. /**
  36204. * Minimum allowed distance of the camera to the axis of rotation
  36205. * (The camera can not get closer).
  36206. * This can help limiting how the Camera is able to move in the scene.
  36207. */
  36208. lowerRadiusLimit: Nullable<number>;
  36209. /**
  36210. * Maximum allowed distance of the camera to the axis of rotation
  36211. * (The camera can not get further).
  36212. * This can help limiting how the Camera is able to move in the scene.
  36213. */
  36214. upperRadiusLimit: Nullable<number>;
  36215. /**
  36216. * Define a rotation offset between the camera and the object it follows
  36217. */
  36218. rotationOffset: number;
  36219. /**
  36220. * Minimum allowed angle to camera position relative to target object.
  36221. * This can help limiting how the Camera is able to move in the scene.
  36222. */
  36223. lowerRotationOffsetLimit: Nullable<number>;
  36224. /**
  36225. * Maximum allowed angle to camera position relative to target object.
  36226. * This can help limiting how the Camera is able to move in the scene.
  36227. */
  36228. upperRotationOffsetLimit: Nullable<number>;
  36229. /**
  36230. * Define a height offset between the camera and the object it follows.
  36231. * It can help following an object from the top (like a car chaing a plane)
  36232. */
  36233. heightOffset: number;
  36234. /**
  36235. * Minimum allowed height of camera position relative to target object.
  36236. * This can help limiting how the Camera is able to move in the scene.
  36237. */
  36238. lowerHeightOffsetLimit: Nullable<number>;
  36239. /**
  36240. * Maximum allowed height of camera position relative to target object.
  36241. * This can help limiting how the Camera is able to move in the scene.
  36242. */
  36243. upperHeightOffsetLimit: Nullable<number>;
  36244. /**
  36245. * Define how fast the camera can accelerate to follow it s target.
  36246. */
  36247. cameraAcceleration: number;
  36248. /**
  36249. * Define the speed limit of the camera following an object.
  36250. */
  36251. maxCameraSpeed: number;
  36252. /**
  36253. * Define the target of the camera.
  36254. */
  36255. lockedTarget: Nullable<AbstractMesh>;
  36256. /**
  36257. * Defines the input associated with the camera.
  36258. */
  36259. inputs: FollowCameraInputsManager;
  36260. /**
  36261. * Instantiates the follow camera.
  36262. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36263. * @param name Define the name of the camera in the scene
  36264. * @param position Define the position of the camera
  36265. * @param scene Define the scene the camera belong to
  36266. * @param lockedTarget Define the target of the camera
  36267. */
  36268. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  36269. private _follow;
  36270. /**
  36271. * Attached controls to the current camera.
  36272. * @param element Defines the element the controls should be listened from
  36273. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36274. */
  36275. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36276. /**
  36277. * Detach the current controls from the camera.
  36278. * The camera will stop reacting to inputs.
  36279. * @param element Defines the element to stop listening the inputs from
  36280. */
  36281. detachControl(element: HTMLElement): void;
  36282. /** @hidden */ private _checkInputs(): void;
  36283. private _checkLimits;
  36284. /**
  36285. * Gets the camera class name.
  36286. * @returns the class name
  36287. */
  36288. getClassName(): string;
  36289. }
  36290. /**
  36291. * Arc Rotate version of the follow camera.
  36292. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  36293. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36294. */
  36295. export class ArcFollowCamera extends TargetCamera {
  36296. /** The longitudinal angle of the camera */
  36297. alpha: number;
  36298. /** The latitudinal angle of the camera */
  36299. beta: number;
  36300. /** The radius of the camera from its target */
  36301. radius: number;
  36302. /** Define the camera target (the messh it should follow) */
  36303. target: Nullable<AbstractMesh>;
  36304. private _cartesianCoordinates;
  36305. /**
  36306. * Instantiates a new ArcFollowCamera
  36307. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36308. * @param name Define the name of the camera
  36309. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  36310. * @param beta Define the rotation angle of the camera around the elevation axis
  36311. * @param radius Define the radius of the camera from its target point
  36312. * @param target Define the target of the camera
  36313. * @param scene Define the scene the camera belongs to
  36314. */
  36315. constructor(name: string,
  36316. /** The longitudinal angle of the camera */
  36317. alpha: number,
  36318. /** The latitudinal angle of the camera */
  36319. beta: number,
  36320. /** The radius of the camera from its target */
  36321. radius: number,
  36322. /** Define the camera target (the messh it should follow) */
  36323. target: Nullable<AbstractMesh>, scene: Scene);
  36324. private _follow;
  36325. /** @hidden */ private _checkInputs(): void;
  36326. /**
  36327. * Returns the class name of the object.
  36328. * It is mostly used internally for serialization purposes.
  36329. */
  36330. getClassName(): string;
  36331. }
  36332. }
  36333. declare module BABYLON {
  36334. /**
  36335. * Manage the keyboard inputs to control the movement of a follow camera.
  36336. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36337. */
  36338. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  36339. /**
  36340. * Defines the camera the input is attached to.
  36341. */
  36342. camera: FollowCamera;
  36343. /**
  36344. * Defines the list of key codes associated with the up action (increase heightOffset)
  36345. */
  36346. keysHeightOffsetIncr: number[];
  36347. /**
  36348. * Defines the list of key codes associated with the down action (decrease heightOffset)
  36349. */
  36350. keysHeightOffsetDecr: number[];
  36351. /**
  36352. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  36353. */
  36354. keysHeightOffsetModifierAlt: boolean;
  36355. /**
  36356. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  36357. */
  36358. keysHeightOffsetModifierCtrl: boolean;
  36359. /**
  36360. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  36361. */
  36362. keysHeightOffsetModifierShift: boolean;
  36363. /**
  36364. * Defines the list of key codes associated with the left action (increase rotationOffset)
  36365. */
  36366. keysRotationOffsetIncr: number[];
  36367. /**
  36368. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  36369. */
  36370. keysRotationOffsetDecr: number[];
  36371. /**
  36372. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  36373. */
  36374. keysRotationOffsetModifierAlt: boolean;
  36375. /**
  36376. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  36377. */
  36378. keysRotationOffsetModifierCtrl: boolean;
  36379. /**
  36380. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  36381. */
  36382. keysRotationOffsetModifierShift: boolean;
  36383. /**
  36384. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  36385. */
  36386. keysRadiusIncr: number[];
  36387. /**
  36388. * Defines the list of key codes associated with the zoom-out action (increase radius)
  36389. */
  36390. keysRadiusDecr: number[];
  36391. /**
  36392. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  36393. */
  36394. keysRadiusModifierAlt: boolean;
  36395. /**
  36396. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  36397. */
  36398. keysRadiusModifierCtrl: boolean;
  36399. /**
  36400. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  36401. */
  36402. keysRadiusModifierShift: boolean;
  36403. /**
  36404. * Defines the rate of change of heightOffset.
  36405. */
  36406. heightSensibility: number;
  36407. /**
  36408. * Defines the rate of change of rotationOffset.
  36409. */
  36410. rotationSensibility: number;
  36411. /**
  36412. * Defines the rate of change of radius.
  36413. */
  36414. radiusSensibility: number;
  36415. private _keys;
  36416. private _ctrlPressed;
  36417. private _altPressed;
  36418. private _shiftPressed;
  36419. private _onCanvasBlurObserver;
  36420. private _onKeyboardObserver;
  36421. private _engine;
  36422. private _scene;
  36423. /**
  36424. * Attach the input controls to a specific dom element to get the input from.
  36425. * @param element Defines the element the controls should be listened from
  36426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36427. */
  36428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36429. /**
  36430. * Detach the current controls from the specified dom element.
  36431. * @param element Defines the element to stop listening the inputs from
  36432. */
  36433. detachControl(element: Nullable<HTMLElement>): void;
  36434. /**
  36435. * Update the current camera state depending on the inputs that have been used this frame.
  36436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36437. */
  36438. checkInputs(): void;
  36439. /**
  36440. * Gets the class name of the current input.
  36441. * @returns the class name
  36442. */
  36443. getClassName(): string;
  36444. /**
  36445. * Get the friendly name associated with the input class.
  36446. * @returns the input friendly name
  36447. */
  36448. getSimpleName(): string;
  36449. /**
  36450. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36451. * allow modification of the heightOffset value.
  36452. */
  36453. private _modifierHeightOffset;
  36454. /**
  36455. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36456. * allow modification of the rotationOffset value.
  36457. */
  36458. private _modifierRotationOffset;
  36459. /**
  36460. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  36461. * allow modification of the radius value.
  36462. */
  36463. private _modifierRadius;
  36464. }
  36465. }
  36466. declare module BABYLON {
  36467. interface FreeCameraInputsManager {
  36468. /**
  36469. * @hidden
  36470. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  36471. /**
  36472. * Add orientation input support to the input manager.
  36473. * @returns the current input manager
  36474. */
  36475. addDeviceOrientation(): FreeCameraInputsManager;
  36476. }
  36477. /**
  36478. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  36479. * Screen rotation is taken into account.
  36480. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36481. */
  36482. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  36483. private _camera;
  36484. private _screenOrientationAngle;
  36485. private _constantTranform;
  36486. private _screenQuaternion;
  36487. private _alpha;
  36488. private _beta;
  36489. private _gamma;
  36490. /**
  36491. * @hidden
  36492. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  36493. /**
  36494. * Instantiates a new input
  36495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36496. */
  36497. constructor();
  36498. /**
  36499. * Define the camera controlled by the input.
  36500. */
  36501. camera: FreeCamera;
  36502. /**
  36503. * Attach the input controls to a specific dom element to get the input from.
  36504. * @param element Defines the element the controls should be listened from
  36505. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36506. */
  36507. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36508. private _orientationChanged;
  36509. private _deviceOrientation;
  36510. /**
  36511. * Detach the current controls from the specified dom element.
  36512. * @param element Defines the element to stop listening the inputs from
  36513. */
  36514. detachControl(element: Nullable<HTMLElement>): void;
  36515. /**
  36516. * Update the current camera state depending on the inputs that have been used this frame.
  36517. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36518. */
  36519. checkInputs(): void;
  36520. /**
  36521. * Gets the class name of the current intput.
  36522. * @returns the class name
  36523. */
  36524. getClassName(): string;
  36525. /**
  36526. * Get the friendly name associated with the input class.
  36527. * @returns the input friendly name
  36528. */
  36529. getSimpleName(): string;
  36530. }
  36531. }
  36532. declare module BABYLON {
  36533. /**
  36534. * Manage the gamepad inputs to control a free camera.
  36535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36536. */
  36537. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  36538. /**
  36539. * Define the camera the input is attached to.
  36540. */
  36541. camera: FreeCamera;
  36542. /**
  36543. * Define the Gamepad controlling the input
  36544. */
  36545. gamepad: Nullable<Gamepad>;
  36546. /**
  36547. * Defines the gamepad rotation sensiblity.
  36548. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36549. */
  36550. gamepadAngularSensibility: number;
  36551. /**
  36552. * Defines the gamepad move sensiblity.
  36553. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36554. */
  36555. gamepadMoveSensibility: number;
  36556. private _onGamepadConnectedObserver;
  36557. private _onGamepadDisconnectedObserver;
  36558. private _cameraTransform;
  36559. private _deltaTransform;
  36560. private _vector3;
  36561. private _vector2;
  36562. /**
  36563. * Attach the input controls to a specific dom element to get the input from.
  36564. * @param element Defines the element the controls should be listened from
  36565. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36566. */
  36567. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36568. /**
  36569. * Detach the current controls from the specified dom element.
  36570. * @param element Defines the element to stop listening the inputs from
  36571. */
  36572. detachControl(element: Nullable<HTMLElement>): void;
  36573. /**
  36574. * Update the current camera state depending on the inputs that have been used this frame.
  36575. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36576. */
  36577. checkInputs(): void;
  36578. /**
  36579. * Gets the class name of the current intput.
  36580. * @returns the class name
  36581. */
  36582. getClassName(): string;
  36583. /**
  36584. * Get the friendly name associated with the input class.
  36585. * @returns the input friendly name
  36586. */
  36587. getSimpleName(): string;
  36588. }
  36589. }
  36590. declare module BABYLON {
  36591. /**
  36592. * Defines the potential axis of a Joystick
  36593. */
  36594. export enum JoystickAxis {
  36595. /** X axis */
  36596. X = 0,
  36597. /** Y axis */
  36598. Y = 1,
  36599. /** Z axis */
  36600. Z = 2
  36601. }
  36602. /**
  36603. * Class used to define virtual joystick (used in touch mode)
  36604. */
  36605. export class VirtualJoystick {
  36606. /**
  36607. * Gets or sets a boolean indicating that left and right values must be inverted
  36608. */
  36609. reverseLeftRight: boolean;
  36610. /**
  36611. * Gets or sets a boolean indicating that up and down values must be inverted
  36612. */
  36613. reverseUpDown: boolean;
  36614. /**
  36615. * Gets the offset value for the position (ie. the change of the position value)
  36616. */
  36617. deltaPosition: Vector3;
  36618. /**
  36619. * Gets a boolean indicating if the virtual joystick was pressed
  36620. */
  36621. pressed: boolean;
  36622. /**
  36623. * Canvas the virtual joystick will render onto, default z-index of this is 5
  36624. */
  36625. static Canvas: Nullable<HTMLCanvasElement>;
  36626. private static _globalJoystickIndex;
  36627. private static vjCanvasContext;
  36628. private static vjCanvasWidth;
  36629. private static vjCanvasHeight;
  36630. private static halfWidth;
  36631. private _action;
  36632. private _axisTargetedByLeftAndRight;
  36633. private _axisTargetedByUpAndDown;
  36634. private _joystickSensibility;
  36635. private _inversedSensibility;
  36636. private _joystickPointerID;
  36637. private _joystickColor;
  36638. private _joystickPointerPos;
  36639. private _joystickPreviousPointerPos;
  36640. private _joystickPointerStartPos;
  36641. private _deltaJoystickVector;
  36642. private _leftJoystick;
  36643. private _touches;
  36644. private _onPointerDownHandlerRef;
  36645. private _onPointerMoveHandlerRef;
  36646. private _onPointerUpHandlerRef;
  36647. private _onResize;
  36648. /**
  36649. * Creates a new virtual joystick
  36650. * @param leftJoystick defines that the joystick is for left hand (false by default)
  36651. */
  36652. constructor(leftJoystick?: boolean);
  36653. /**
  36654. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  36655. * @param newJoystickSensibility defines the new sensibility
  36656. */
  36657. setJoystickSensibility(newJoystickSensibility: number): void;
  36658. private _onPointerDown;
  36659. private _onPointerMove;
  36660. private _onPointerUp;
  36661. /**
  36662. * Change the color of the virtual joystick
  36663. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  36664. */
  36665. setJoystickColor(newColor: string): void;
  36666. /**
  36667. * Defines a callback to call when the joystick is touched
  36668. * @param action defines the callback
  36669. */
  36670. setActionOnTouch(action: () => any): void;
  36671. /**
  36672. * Defines which axis you'd like to control for left & right
  36673. * @param axis defines the axis to use
  36674. */
  36675. setAxisForLeftRight(axis: JoystickAxis): void;
  36676. /**
  36677. * Defines which axis you'd like to control for up & down
  36678. * @param axis defines the axis to use
  36679. */
  36680. setAxisForUpDown(axis: JoystickAxis): void;
  36681. private _drawVirtualJoystick;
  36682. /**
  36683. * Release internal HTML canvas
  36684. */
  36685. releaseCanvas(): void;
  36686. }
  36687. }
  36688. declare module BABYLON {
  36689. interface FreeCameraInputsManager {
  36690. /**
  36691. * Add virtual joystick input support to the input manager.
  36692. * @returns the current input manager
  36693. */
  36694. addVirtualJoystick(): FreeCameraInputsManager;
  36695. }
  36696. /**
  36697. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  36698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36699. */
  36700. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  36701. /**
  36702. * Defines the camera the input is attached to.
  36703. */
  36704. camera: FreeCamera;
  36705. private _leftjoystick;
  36706. private _rightjoystick;
  36707. /**
  36708. * Gets the left stick of the virtual joystick.
  36709. * @returns The virtual Joystick
  36710. */
  36711. getLeftJoystick(): VirtualJoystick;
  36712. /**
  36713. * Gets the right stick of the virtual joystick.
  36714. * @returns The virtual Joystick
  36715. */
  36716. getRightJoystick(): VirtualJoystick;
  36717. /**
  36718. * Update the current camera state depending on the inputs that have been used this frame.
  36719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36720. */
  36721. checkInputs(): void;
  36722. /**
  36723. * Attach the input controls to a specific dom element to get the input from.
  36724. * @param element Defines the element the controls should be listened from
  36725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36726. */
  36727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36728. /**
  36729. * Detach the current controls from the specified dom element.
  36730. * @param element Defines the element to stop listening the inputs from
  36731. */
  36732. detachControl(element: Nullable<HTMLElement>): void;
  36733. /**
  36734. * Gets the class name of the current intput.
  36735. * @returns the class name
  36736. */
  36737. getClassName(): string;
  36738. /**
  36739. * Get the friendly name associated with the input class.
  36740. * @returns the input friendly name
  36741. */
  36742. getSimpleName(): string;
  36743. }
  36744. }
  36745. declare module BABYLON {
  36746. /**
  36747. * This represents a FPS type of camera controlled by touch.
  36748. * This is like a universal camera minus the Gamepad controls.
  36749. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36750. */
  36751. export class TouchCamera extends FreeCamera {
  36752. /**
  36753. * Defines the touch sensibility for rotation.
  36754. * The higher the faster.
  36755. */
  36756. touchAngularSensibility: number;
  36757. /**
  36758. * Defines the touch sensibility for move.
  36759. * The higher the faster.
  36760. */
  36761. touchMoveSensibility: number;
  36762. /**
  36763. * Instantiates a new touch camera.
  36764. * This represents a FPS type of camera controlled by touch.
  36765. * This is like a universal camera minus the Gamepad controls.
  36766. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  36767. * @param name Define the name of the camera in the scene
  36768. * @param position Define the start position of the camera in the scene
  36769. * @param scene Define the scene the camera belongs to
  36770. */
  36771. constructor(name: string, position: Vector3, scene: Scene);
  36772. /**
  36773. * Gets the current object class name.
  36774. * @return the class name
  36775. */
  36776. getClassName(): string;
  36777. /** @hidden */ private _setupInputs(): void;
  36778. }
  36779. }
  36780. declare module BABYLON {
  36781. /**
  36782. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  36783. * being tilted forward or back and left or right.
  36784. */
  36785. export class DeviceOrientationCamera extends FreeCamera {
  36786. private _initialQuaternion;
  36787. private _quaternionCache;
  36788. private _tmpDragQuaternion;
  36789. /**
  36790. * Creates a new device orientation camera
  36791. * @param name The name of the camera
  36792. * @param position The start position camera
  36793. * @param scene The scene the camera belongs to
  36794. */
  36795. constructor(name: string, position: Vector3, scene: Scene);
  36796. /**
  36797. * @hidden
  36798. * Disabled pointer input on first orientation sensor update (Default: true)
  36799. */ private _disablePointerInputWhenUsingDeviceOrientation: boolean;
  36800. private _dragFactor;
  36801. /**
  36802. * Enabled turning on the y axis when the orientation sensor is active
  36803. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  36804. */
  36805. enableHorizontalDragging(dragFactor?: number): void;
  36806. /**
  36807. * Gets the current instance class name ("DeviceOrientationCamera").
  36808. * This helps avoiding instanceof at run time.
  36809. * @returns the class name
  36810. */
  36811. getClassName(): string;
  36812. /**
  36813. * @hidden
  36814. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  36815. */ private _checkInputs(): void;
  36816. /**
  36817. * Reset the camera to its default orientation on the specified axis only.
  36818. * @param axis The axis to reset
  36819. */
  36820. resetToCurrentRotation(axis?: Axis): void;
  36821. }
  36822. }
  36823. declare module BABYLON {
  36824. /**
  36825. * Defines supported buttons for XBox360 compatible gamepads
  36826. */
  36827. export enum Xbox360Button {
  36828. /** A */
  36829. A = 0,
  36830. /** B */
  36831. B = 1,
  36832. /** X */
  36833. X = 2,
  36834. /** Y */
  36835. Y = 3,
  36836. /** Start */
  36837. Start = 4,
  36838. /** Back */
  36839. Back = 5,
  36840. /** Left button */
  36841. LB = 6,
  36842. /** Right button */
  36843. RB = 7,
  36844. /** Left stick */
  36845. LeftStick = 8,
  36846. /** Right stick */
  36847. RightStick = 9
  36848. }
  36849. /** Defines values for XBox360 DPad */
  36850. export enum Xbox360Dpad {
  36851. /** Up */
  36852. Up = 0,
  36853. /** Down */
  36854. Down = 1,
  36855. /** Left */
  36856. Left = 2,
  36857. /** Right */
  36858. Right = 3
  36859. }
  36860. /**
  36861. * Defines a XBox360 gamepad
  36862. */
  36863. export class Xbox360Pad extends Gamepad {
  36864. private _leftTrigger;
  36865. private _rightTrigger;
  36866. private _onlefttriggerchanged;
  36867. private _onrighttriggerchanged;
  36868. private _onbuttondown;
  36869. private _onbuttonup;
  36870. private _ondpaddown;
  36871. private _ondpadup;
  36872. /** Observable raised when a button is pressed */
  36873. onButtonDownObservable: Observable<Xbox360Button>;
  36874. /** Observable raised when a button is released */
  36875. onButtonUpObservable: Observable<Xbox360Button>;
  36876. /** Observable raised when a pad is pressed */
  36877. onPadDownObservable: Observable<Xbox360Dpad>;
  36878. /** Observable raised when a pad is released */
  36879. onPadUpObservable: Observable<Xbox360Dpad>;
  36880. private _buttonA;
  36881. private _buttonB;
  36882. private _buttonX;
  36883. private _buttonY;
  36884. private _buttonBack;
  36885. private _buttonStart;
  36886. private _buttonLB;
  36887. private _buttonRB;
  36888. private _buttonLeftStick;
  36889. private _buttonRightStick;
  36890. private _dPadUp;
  36891. private _dPadDown;
  36892. private _dPadLeft;
  36893. private _dPadRight;
  36894. private _isXboxOnePad;
  36895. /**
  36896. * Creates a new XBox360 gamepad object
  36897. * @param id defines the id of this gamepad
  36898. * @param index defines its index
  36899. * @param gamepad defines the internal HTML gamepad object
  36900. * @param xboxOne defines if it is a XBox One gamepad
  36901. */
  36902. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  36903. /**
  36904. * Defines the callback to call when left trigger is pressed
  36905. * @param callback defines the callback to use
  36906. */
  36907. onlefttriggerchanged(callback: (value: number) => void): void;
  36908. /**
  36909. * Defines the callback to call when right trigger is pressed
  36910. * @param callback defines the callback to use
  36911. */
  36912. onrighttriggerchanged(callback: (value: number) => void): void;
  36913. /**
  36914. * Gets the left trigger value
  36915. */
  36916. /**
  36917. * Sets the left trigger value
  36918. */
  36919. leftTrigger: number;
  36920. /**
  36921. * Gets the right trigger value
  36922. */
  36923. /**
  36924. * Sets the right trigger value
  36925. */
  36926. rightTrigger: number;
  36927. /**
  36928. * Defines the callback to call when a button is pressed
  36929. * @param callback defines the callback to use
  36930. */
  36931. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  36932. /**
  36933. * Defines the callback to call when a button is released
  36934. * @param callback defines the callback to use
  36935. */
  36936. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  36937. /**
  36938. * Defines the callback to call when a pad is pressed
  36939. * @param callback defines the callback to use
  36940. */
  36941. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  36942. /**
  36943. * Defines the callback to call when a pad is released
  36944. * @param callback defines the callback to use
  36945. */
  36946. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  36947. private _setButtonValue;
  36948. private _setDPadValue;
  36949. /**
  36950. * Gets the value of the `A` button
  36951. */
  36952. /**
  36953. * Sets the value of the `A` button
  36954. */
  36955. buttonA: number;
  36956. /**
  36957. * Gets the value of the `B` button
  36958. */
  36959. /**
  36960. * Sets the value of the `B` button
  36961. */
  36962. buttonB: number;
  36963. /**
  36964. * Gets the value of the `X` button
  36965. */
  36966. /**
  36967. * Sets the value of the `X` button
  36968. */
  36969. buttonX: number;
  36970. /**
  36971. * Gets the value of the `Y` button
  36972. */
  36973. /**
  36974. * Sets the value of the `Y` button
  36975. */
  36976. buttonY: number;
  36977. /**
  36978. * Gets the value of the `Start` button
  36979. */
  36980. /**
  36981. * Sets the value of the `Start` button
  36982. */
  36983. buttonStart: number;
  36984. /**
  36985. * Gets the value of the `Back` button
  36986. */
  36987. /**
  36988. * Sets the value of the `Back` button
  36989. */
  36990. buttonBack: number;
  36991. /**
  36992. * Gets the value of the `Left` button
  36993. */
  36994. /**
  36995. * Sets the value of the `Left` button
  36996. */
  36997. buttonLB: number;
  36998. /**
  36999. * Gets the value of the `Right` button
  37000. */
  37001. /**
  37002. * Sets the value of the `Right` button
  37003. */
  37004. buttonRB: number;
  37005. /**
  37006. * Gets the value of the Left joystick
  37007. */
  37008. /**
  37009. * Sets the value of the Left joystick
  37010. */
  37011. buttonLeftStick: number;
  37012. /**
  37013. * Gets the value of the Right joystick
  37014. */
  37015. /**
  37016. * Sets the value of the Right joystick
  37017. */
  37018. buttonRightStick: number;
  37019. /**
  37020. * Gets the value of D-pad up
  37021. */
  37022. /**
  37023. * Sets the value of D-pad up
  37024. */
  37025. dPadUp: number;
  37026. /**
  37027. * Gets the value of D-pad down
  37028. */
  37029. /**
  37030. * Sets the value of D-pad down
  37031. */
  37032. dPadDown: number;
  37033. /**
  37034. * Gets the value of D-pad left
  37035. */
  37036. /**
  37037. * Sets the value of D-pad left
  37038. */
  37039. dPadLeft: number;
  37040. /**
  37041. * Gets the value of D-pad right
  37042. */
  37043. /**
  37044. * Sets the value of D-pad right
  37045. */
  37046. dPadRight: number;
  37047. /**
  37048. * Force the gamepad to synchronize with device values
  37049. */
  37050. update(): void;
  37051. /**
  37052. * Disposes the gamepad
  37053. */
  37054. dispose(): void;
  37055. }
  37056. }
  37057. declare module BABYLON {
  37058. /**
  37059. * Manager for handling gamepads
  37060. */
  37061. export class GamepadManager {
  37062. private _scene?;
  37063. private _babylonGamepads;
  37064. private _oneGamepadConnected;
  37065. /** @hidden */ private _isMonitoring: boolean;
  37066. private _gamepadEventSupported;
  37067. private _gamepadSupport;
  37068. /**
  37069. * observable to be triggered when the gamepad controller has been connected
  37070. */
  37071. onGamepadConnectedObservable: Observable<Gamepad>;
  37072. /**
  37073. * observable to be triggered when the gamepad controller has been disconnected
  37074. */
  37075. onGamepadDisconnectedObservable: Observable<Gamepad>;
  37076. private _onGamepadConnectedEvent;
  37077. private _onGamepadDisconnectedEvent;
  37078. /**
  37079. * Initializes the gamepad manager
  37080. * @param _scene BabylonJS scene
  37081. */
  37082. constructor(_scene?: Scene | undefined);
  37083. /**
  37084. * The gamepads in the game pad manager
  37085. */
  37086. readonly gamepads: Gamepad[];
  37087. /**
  37088. * Get the gamepad controllers based on type
  37089. * @param type The type of gamepad controller
  37090. * @returns Nullable gamepad
  37091. */
  37092. getGamepadByType(type?: number): Nullable<Gamepad>;
  37093. /**
  37094. * Disposes the gamepad manager
  37095. */
  37096. dispose(): void;
  37097. private _addNewGamepad;
  37098. private _startMonitoringGamepads;
  37099. private _stopMonitoringGamepads;
  37100. /** @hidden */ private _checkGamepadsStatus(): void;
  37101. private _updateGamepadObjects;
  37102. }
  37103. }
  37104. declare module BABYLON {
  37105. interface Scene {
  37106. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  37107. /**
  37108. * Gets the gamepad manager associated with the scene
  37109. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  37110. */
  37111. gamepadManager: GamepadManager;
  37112. }
  37113. /**
  37114. * Interface representing a free camera inputs manager
  37115. */
  37116. interface FreeCameraInputsManager {
  37117. /**
  37118. * Adds gamepad input support to the FreeCameraInputsManager.
  37119. * @returns the FreeCameraInputsManager
  37120. */
  37121. addGamepad(): FreeCameraInputsManager;
  37122. }
  37123. /**
  37124. * Interface representing an arc rotate camera inputs manager
  37125. */
  37126. interface ArcRotateCameraInputsManager {
  37127. /**
  37128. * Adds gamepad input support to the ArcRotateCamera InputManager.
  37129. * @returns the camera inputs manager
  37130. */
  37131. addGamepad(): ArcRotateCameraInputsManager;
  37132. }
  37133. /**
  37134. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  37135. */
  37136. export class GamepadSystemSceneComponent implements ISceneComponent {
  37137. /**
  37138. * The component name helpfull to identify the component in the list of scene components.
  37139. */
  37140. readonly name: string;
  37141. /**
  37142. * The scene the component belongs to.
  37143. */
  37144. scene: Scene;
  37145. /**
  37146. * Creates a new instance of the component for the given scene
  37147. * @param scene Defines the scene to register the component in
  37148. */
  37149. constructor(scene: Scene);
  37150. /**
  37151. * Registers the component in a given scene
  37152. */
  37153. register(): void;
  37154. /**
  37155. * Rebuilds the elements related to this component in case of
  37156. * context lost for instance.
  37157. */
  37158. rebuild(): void;
  37159. /**
  37160. * Disposes the component and the associated ressources
  37161. */
  37162. dispose(): void;
  37163. private _beforeCameraUpdate;
  37164. }
  37165. }
  37166. declare module BABYLON {
  37167. /**
  37168. * 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,
  37169. * which still works and will still be found in many Playgrounds.
  37170. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37171. */
  37172. export class UniversalCamera extends TouchCamera {
  37173. /**
  37174. * Defines the gamepad rotation sensiblity.
  37175. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37176. */
  37177. gamepadAngularSensibility: number;
  37178. /**
  37179. * Defines the gamepad move sensiblity.
  37180. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37181. */
  37182. gamepadMoveSensibility: number;
  37183. /**
  37184. * 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,
  37185. * which still works and will still be found in many Playgrounds.
  37186. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37187. * @param name Define the name of the camera in the scene
  37188. * @param position Define the start position of the camera in the scene
  37189. * @param scene Define the scene the camera belongs to
  37190. */
  37191. constructor(name: string, position: Vector3, scene: Scene);
  37192. /**
  37193. * Gets the current object class name.
  37194. * @return the class name
  37195. */
  37196. getClassName(): string;
  37197. }
  37198. }
  37199. declare module BABYLON {
  37200. /**
  37201. * This represents a FPS type of camera. This is only here for back compat purpose.
  37202. * Please use the UniversalCamera instead as both are identical.
  37203. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37204. */
  37205. export class GamepadCamera extends UniversalCamera {
  37206. /**
  37207. * Instantiates a new Gamepad Camera
  37208. * This represents a FPS type of camera. This is only here for back compat purpose.
  37209. * Please use the UniversalCamera instead as both are identical.
  37210. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37211. * @param name Define the name of the camera in the scene
  37212. * @param position Define the start position of the camera in the scene
  37213. * @param scene Define the scene the camera belongs to
  37214. */
  37215. constructor(name: string, position: Vector3, scene: Scene);
  37216. /**
  37217. * Gets the current object class name.
  37218. * @return the class name
  37219. */
  37220. getClassName(): string;
  37221. }
  37222. }
  37223. declare module BABYLON {
  37224. /** @hidden */
  37225. export var passPixelShader: {
  37226. name: string;
  37227. shader: string;
  37228. };
  37229. }
  37230. declare module BABYLON {
  37231. /** @hidden */
  37232. export var passCubePixelShader: {
  37233. name: string;
  37234. shader: string;
  37235. };
  37236. }
  37237. declare module BABYLON {
  37238. /**
  37239. * PassPostProcess which produces an output the same as it's input
  37240. */
  37241. export class PassPostProcess extends PostProcess {
  37242. /**
  37243. * Creates the PassPostProcess
  37244. * @param name The name of the effect.
  37245. * @param options The required width/height ratio to downsize to before computing the render pass.
  37246. * @param camera The camera to apply the render pass to.
  37247. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37248. * @param engine The engine which the post process will be applied. (default: current engine)
  37249. * @param reusable If the post process can be reused on the same frame. (default: false)
  37250. * @param textureType The type of texture to be used when performing the post processing.
  37251. * @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)
  37252. */
  37253. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37254. }
  37255. /**
  37256. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  37257. */
  37258. export class PassCubePostProcess extends PostProcess {
  37259. private _face;
  37260. /**
  37261. * Gets or sets the cube face to display.
  37262. * * 0 is +X
  37263. * * 1 is -X
  37264. * * 2 is +Y
  37265. * * 3 is -Y
  37266. * * 4 is +Z
  37267. * * 5 is -Z
  37268. */
  37269. face: number;
  37270. /**
  37271. * Creates the PassCubePostProcess
  37272. * @param name The name of the effect.
  37273. * @param options The required width/height ratio to downsize to before computing the render pass.
  37274. * @param camera The camera to apply the render pass to.
  37275. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37276. * @param engine The engine which the post process will be applied. (default: current engine)
  37277. * @param reusable If the post process can be reused on the same frame. (default: false)
  37278. * @param textureType The type of texture to be used when performing the post processing.
  37279. * @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)
  37280. */
  37281. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  37282. }
  37283. }
  37284. declare module BABYLON {
  37285. /** @hidden */
  37286. export var anaglyphPixelShader: {
  37287. name: string;
  37288. shader: string;
  37289. };
  37290. }
  37291. declare module BABYLON {
  37292. /**
  37293. * Postprocess used to generate anaglyphic rendering
  37294. */
  37295. export class AnaglyphPostProcess extends PostProcess {
  37296. private _passedProcess;
  37297. /**
  37298. * Creates a new AnaglyphPostProcess
  37299. * @param name defines postprocess name
  37300. * @param options defines creation options or target ratio scale
  37301. * @param rigCameras defines cameras using this postprocess
  37302. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  37303. * @param engine defines hosting engine
  37304. * @param reusable defines if the postprocess will be reused multiple times per frame
  37305. */
  37306. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  37307. }
  37308. }
  37309. declare module BABYLON {
  37310. /**
  37311. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  37312. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37313. */
  37314. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  37315. /**
  37316. * Creates a new AnaglyphArcRotateCamera
  37317. * @param name defines camera name
  37318. * @param alpha defines alpha angle (in radians)
  37319. * @param beta defines beta angle (in radians)
  37320. * @param radius defines radius
  37321. * @param target defines camera target
  37322. * @param interaxialDistance defines distance between each color axis
  37323. * @param scene defines the hosting scene
  37324. */
  37325. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  37326. /**
  37327. * Gets camera class name
  37328. * @returns AnaglyphArcRotateCamera
  37329. */
  37330. getClassName(): string;
  37331. }
  37332. }
  37333. declare module BABYLON {
  37334. /**
  37335. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  37336. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37337. */
  37338. export class AnaglyphFreeCamera extends FreeCamera {
  37339. /**
  37340. * Creates a new AnaglyphFreeCamera
  37341. * @param name defines camera name
  37342. * @param position defines initial position
  37343. * @param interaxialDistance defines distance between each color axis
  37344. * @param scene defines the hosting scene
  37345. */
  37346. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37347. /**
  37348. * Gets camera class name
  37349. * @returns AnaglyphFreeCamera
  37350. */
  37351. getClassName(): string;
  37352. }
  37353. }
  37354. declare module BABYLON {
  37355. /**
  37356. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  37357. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37358. */
  37359. export class AnaglyphGamepadCamera extends GamepadCamera {
  37360. /**
  37361. * Creates a new AnaglyphGamepadCamera
  37362. * @param name defines camera name
  37363. * @param position defines initial position
  37364. * @param interaxialDistance defines distance between each color axis
  37365. * @param scene defines the hosting scene
  37366. */
  37367. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37368. /**
  37369. * Gets camera class name
  37370. * @returns AnaglyphGamepadCamera
  37371. */
  37372. getClassName(): string;
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. /**
  37377. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  37378. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  37379. */
  37380. export class AnaglyphUniversalCamera extends UniversalCamera {
  37381. /**
  37382. * Creates a new AnaglyphUniversalCamera
  37383. * @param name defines camera name
  37384. * @param position defines initial position
  37385. * @param interaxialDistance defines distance between each color axis
  37386. * @param scene defines the hosting scene
  37387. */
  37388. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  37389. /**
  37390. * Gets camera class name
  37391. * @returns AnaglyphUniversalCamera
  37392. */
  37393. getClassName(): string;
  37394. }
  37395. }
  37396. declare module BABYLON {
  37397. /** @hidden */
  37398. export var stereoscopicInterlacePixelShader: {
  37399. name: string;
  37400. shader: string;
  37401. };
  37402. }
  37403. declare module BABYLON {
  37404. /**
  37405. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  37406. */
  37407. export class StereoscopicInterlacePostProcess extends PostProcess {
  37408. private _stepSize;
  37409. private _passedProcess;
  37410. /**
  37411. * Initializes a StereoscopicInterlacePostProcess
  37412. * @param name The name of the effect.
  37413. * @param rigCameras The rig cameras to be appled to the post process
  37414. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  37415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  37416. * @param engine The engine which the post process will be applied. (default: current engine)
  37417. * @param reusable If the post process can be reused on the same frame. (default: false)
  37418. */
  37419. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  37420. }
  37421. }
  37422. declare module BABYLON {
  37423. /**
  37424. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  37425. * @see http://doc.babylonjs.com/features/cameras
  37426. */
  37427. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  37428. /**
  37429. * Creates a new StereoscopicArcRotateCamera
  37430. * @param name defines camera name
  37431. * @param alpha defines alpha angle (in radians)
  37432. * @param beta defines beta angle (in radians)
  37433. * @param radius defines radius
  37434. * @param target defines camera target
  37435. * @param interaxialDistance defines distance between each color axis
  37436. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37437. * @param scene defines the hosting scene
  37438. */
  37439. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37440. /**
  37441. * Gets camera class name
  37442. * @returns StereoscopicArcRotateCamera
  37443. */
  37444. getClassName(): string;
  37445. }
  37446. }
  37447. declare module BABYLON {
  37448. /**
  37449. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  37450. * @see http://doc.babylonjs.com/features/cameras
  37451. */
  37452. export class StereoscopicFreeCamera extends FreeCamera {
  37453. /**
  37454. * Creates a new StereoscopicFreeCamera
  37455. * @param name defines camera name
  37456. * @param position defines initial position
  37457. * @param interaxialDistance defines distance between each color axis
  37458. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37459. * @param scene defines the hosting scene
  37460. */
  37461. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37462. /**
  37463. * Gets camera class name
  37464. * @returns StereoscopicFreeCamera
  37465. */
  37466. getClassName(): string;
  37467. }
  37468. }
  37469. declare module BABYLON {
  37470. /**
  37471. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  37472. * @see http://doc.babylonjs.com/features/cameras
  37473. */
  37474. export class StereoscopicGamepadCamera extends GamepadCamera {
  37475. /**
  37476. * Creates a new StereoscopicGamepadCamera
  37477. * @param name defines camera name
  37478. * @param position defines initial position
  37479. * @param interaxialDistance defines distance between each color axis
  37480. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37481. * @param scene defines the hosting scene
  37482. */
  37483. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37484. /**
  37485. * Gets camera class name
  37486. * @returns StereoscopicGamepadCamera
  37487. */
  37488. getClassName(): string;
  37489. }
  37490. }
  37491. declare module BABYLON {
  37492. /**
  37493. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  37494. * @see http://doc.babylonjs.com/features/cameras
  37495. */
  37496. export class StereoscopicUniversalCamera extends UniversalCamera {
  37497. /**
  37498. * Creates a new StereoscopicUniversalCamera
  37499. * @param name defines camera name
  37500. * @param position defines initial position
  37501. * @param interaxialDistance defines distance between each color axis
  37502. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  37503. * @param scene defines the hosting scene
  37504. */
  37505. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  37506. /**
  37507. * Gets camera class name
  37508. * @returns StereoscopicUniversalCamera
  37509. */
  37510. getClassName(): string;
  37511. }
  37512. }
  37513. declare module BABYLON {
  37514. /**
  37515. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  37516. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37517. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37518. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37519. */
  37520. export class VirtualJoysticksCamera extends FreeCamera {
  37521. /**
  37522. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  37523. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  37524. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  37525. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  37526. * @param name Define the name of the camera in the scene
  37527. * @param position Define the start position of the camera in the scene
  37528. * @param scene Define the scene the camera belongs to
  37529. */
  37530. constructor(name: string, position: Vector3, scene: Scene);
  37531. /**
  37532. * Gets the current object class name.
  37533. * @return the class name
  37534. */
  37535. getClassName(): string;
  37536. }
  37537. }
  37538. declare module BABYLON {
  37539. /**
  37540. * This represents all the required metrics to create a VR camera.
  37541. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  37542. */
  37543. export class VRCameraMetrics {
  37544. /**
  37545. * Define the horizontal resolution off the screen.
  37546. */
  37547. hResolution: number;
  37548. /**
  37549. * Define the vertical resolution off the screen.
  37550. */
  37551. vResolution: number;
  37552. /**
  37553. * Define the horizontal screen size.
  37554. */
  37555. hScreenSize: number;
  37556. /**
  37557. * Define the vertical screen size.
  37558. */
  37559. vScreenSize: number;
  37560. /**
  37561. * Define the vertical screen center position.
  37562. */
  37563. vScreenCenter: number;
  37564. /**
  37565. * Define the distance of the eyes to the screen.
  37566. */
  37567. eyeToScreenDistance: number;
  37568. /**
  37569. * Define the distance between both lenses
  37570. */
  37571. lensSeparationDistance: number;
  37572. /**
  37573. * Define the distance between both viewer's eyes.
  37574. */
  37575. interpupillaryDistance: number;
  37576. /**
  37577. * Define the distortion factor of the VR postprocess.
  37578. * Please, touch with care.
  37579. */
  37580. distortionK: number[];
  37581. /**
  37582. * Define the chromatic aberration correction factors for the VR post process.
  37583. */
  37584. chromaAbCorrection: number[];
  37585. /**
  37586. * Define the scale factor of the post process.
  37587. * The smaller the better but the slower.
  37588. */
  37589. postProcessScaleFactor: number;
  37590. /**
  37591. * Define an offset for the lens center.
  37592. */
  37593. lensCenterOffset: number;
  37594. /**
  37595. * Define if the current vr camera should compensate the distortion of the lense or not.
  37596. */
  37597. compensateDistortion: boolean;
  37598. /**
  37599. * Defines if multiview should be enabled when rendering (Default: false)
  37600. */
  37601. multiviewEnabled: boolean;
  37602. /**
  37603. * Gets the rendering aspect ratio based on the provided resolutions.
  37604. */
  37605. readonly aspectRatio: number;
  37606. /**
  37607. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  37608. */
  37609. readonly aspectRatioFov: number;
  37610. /**
  37611. * @hidden
  37612. */
  37613. readonly leftHMatrix: Matrix;
  37614. /**
  37615. * @hidden
  37616. */
  37617. readonly rightHMatrix: Matrix;
  37618. /**
  37619. * @hidden
  37620. */
  37621. readonly leftPreViewMatrix: Matrix;
  37622. /**
  37623. * @hidden
  37624. */
  37625. readonly rightPreViewMatrix: Matrix;
  37626. /**
  37627. * Get the default VRMetrics based on the most generic setup.
  37628. * @returns the default vr metrics
  37629. */
  37630. static GetDefault(): VRCameraMetrics;
  37631. }
  37632. }
  37633. declare module BABYLON {
  37634. /** @hidden */
  37635. export var vrDistortionCorrectionPixelShader: {
  37636. name: string;
  37637. shader: string;
  37638. };
  37639. }
  37640. declare module BABYLON {
  37641. /**
  37642. * VRDistortionCorrectionPostProcess used for mobile VR
  37643. */
  37644. export class VRDistortionCorrectionPostProcess extends PostProcess {
  37645. private _isRightEye;
  37646. private _distortionFactors;
  37647. private _postProcessScaleFactor;
  37648. private _lensCenterOffset;
  37649. private _scaleIn;
  37650. private _scaleFactor;
  37651. private _lensCenter;
  37652. /**
  37653. * Initializes the VRDistortionCorrectionPostProcess
  37654. * @param name The name of the effect.
  37655. * @param camera The camera to apply the render pass to.
  37656. * @param isRightEye If this is for the right eye distortion
  37657. * @param vrMetrics All the required metrics for the VR camera
  37658. */
  37659. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  37660. }
  37661. }
  37662. declare module BABYLON {
  37663. /**
  37664. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  37665. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37666. */
  37667. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  37668. /**
  37669. * Creates a new VRDeviceOrientationArcRotateCamera
  37670. * @param name defines camera name
  37671. * @param alpha defines the camera rotation along the logitudinal axis
  37672. * @param beta defines the camera rotation along the latitudinal axis
  37673. * @param radius defines the camera distance from its target
  37674. * @param target defines the camera target
  37675. * @param scene defines the scene the camera belongs to
  37676. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37677. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37678. */
  37679. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37680. /**
  37681. * Gets camera class name
  37682. * @returns VRDeviceOrientationArcRotateCamera
  37683. */
  37684. getClassName(): string;
  37685. }
  37686. }
  37687. declare module BABYLON {
  37688. /**
  37689. * Camera used to simulate VR rendering (based on FreeCamera)
  37690. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37691. */
  37692. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  37693. /**
  37694. * Creates a new VRDeviceOrientationFreeCamera
  37695. * @param name defines camera name
  37696. * @param position defines the start position of the camera
  37697. * @param scene defines the scene the camera belongs to
  37698. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37699. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37700. */
  37701. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37702. /**
  37703. * Gets camera class name
  37704. * @returns VRDeviceOrientationFreeCamera
  37705. */
  37706. getClassName(): string;
  37707. }
  37708. }
  37709. declare module BABYLON {
  37710. /**
  37711. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  37712. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  37713. */
  37714. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  37715. /**
  37716. * Creates a new VRDeviceOrientationGamepadCamera
  37717. * @param name defines camera name
  37718. * @param position defines the start position of the camera
  37719. * @param scene defines the scene the camera belongs to
  37720. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  37721. * @param vrCameraMetrics defines the vr metrics associated to the camera
  37722. */
  37723. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  37724. /**
  37725. * Gets camera class name
  37726. * @returns VRDeviceOrientationGamepadCamera
  37727. */
  37728. getClassName(): string;
  37729. }
  37730. }
  37731. declare module BABYLON {
  37732. /**
  37733. * Base class of materials working in push mode in babylon JS
  37734. * @hidden
  37735. */
  37736. export class PushMaterial extends Material {
  37737. protected _activeEffect: Effect;
  37738. protected _normalMatrix: Matrix;
  37739. /**
  37740. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  37741. * This means that the material can keep using a previous shader while a new one is being compiled.
  37742. * This is mostly used when shader parallel compilation is supported (true by default)
  37743. */
  37744. allowShaderHotSwapping: boolean;
  37745. constructor(name: string, scene: Scene);
  37746. getEffect(): Effect;
  37747. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  37748. /**
  37749. * Binds the given world matrix to the active effect
  37750. *
  37751. * @param world the matrix to bind
  37752. */
  37753. bindOnlyWorldMatrix(world: Matrix): void;
  37754. /**
  37755. * Binds the given normal matrix to the active effect
  37756. *
  37757. * @param normalMatrix the matrix to bind
  37758. */
  37759. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  37760. bind(world: Matrix, mesh?: Mesh): void;
  37761. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  37762. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  37763. }
  37764. }
  37765. declare module BABYLON {
  37766. /**
  37767. * This groups all the flags used to control the materials channel.
  37768. */
  37769. export class MaterialFlags {
  37770. private static _DiffuseTextureEnabled;
  37771. /**
  37772. * Are diffuse textures enabled in the application.
  37773. */
  37774. static DiffuseTextureEnabled: boolean;
  37775. private static _AmbientTextureEnabled;
  37776. /**
  37777. * Are ambient textures enabled in the application.
  37778. */
  37779. static AmbientTextureEnabled: boolean;
  37780. private static _OpacityTextureEnabled;
  37781. /**
  37782. * Are opacity textures enabled in the application.
  37783. */
  37784. static OpacityTextureEnabled: boolean;
  37785. private static _ReflectionTextureEnabled;
  37786. /**
  37787. * Are reflection textures enabled in the application.
  37788. */
  37789. static ReflectionTextureEnabled: boolean;
  37790. private static _EmissiveTextureEnabled;
  37791. /**
  37792. * Are emissive textures enabled in the application.
  37793. */
  37794. static EmissiveTextureEnabled: boolean;
  37795. private static _SpecularTextureEnabled;
  37796. /**
  37797. * Are specular textures enabled in the application.
  37798. */
  37799. static SpecularTextureEnabled: boolean;
  37800. private static _BumpTextureEnabled;
  37801. /**
  37802. * Are bump textures enabled in the application.
  37803. */
  37804. static BumpTextureEnabled: boolean;
  37805. private static _LightmapTextureEnabled;
  37806. /**
  37807. * Are lightmap textures enabled in the application.
  37808. */
  37809. static LightmapTextureEnabled: boolean;
  37810. private static _RefractionTextureEnabled;
  37811. /**
  37812. * Are refraction textures enabled in the application.
  37813. */
  37814. static RefractionTextureEnabled: boolean;
  37815. private static _ColorGradingTextureEnabled;
  37816. /**
  37817. * Are color grading textures enabled in the application.
  37818. */
  37819. static ColorGradingTextureEnabled: boolean;
  37820. private static _FresnelEnabled;
  37821. /**
  37822. * Are fresnels enabled in the application.
  37823. */
  37824. static FresnelEnabled: boolean;
  37825. private static _ClearCoatTextureEnabled;
  37826. /**
  37827. * Are clear coat textures enabled in the application.
  37828. */
  37829. static ClearCoatTextureEnabled: boolean;
  37830. private static _ClearCoatBumpTextureEnabled;
  37831. /**
  37832. * Are clear coat bump textures enabled in the application.
  37833. */
  37834. static ClearCoatBumpTextureEnabled: boolean;
  37835. private static _ClearCoatTintTextureEnabled;
  37836. /**
  37837. * Are clear coat tint textures enabled in the application.
  37838. */
  37839. static ClearCoatTintTextureEnabled: boolean;
  37840. private static _SheenTextureEnabled;
  37841. /**
  37842. * Are sheen textures enabled in the application.
  37843. */
  37844. static SheenTextureEnabled: boolean;
  37845. private static _AnisotropicTextureEnabled;
  37846. /**
  37847. * Are anisotropic textures enabled in the application.
  37848. */
  37849. static AnisotropicTextureEnabled: boolean;
  37850. private static _ThicknessTextureEnabled;
  37851. /**
  37852. * Are thickness textures enabled in the application.
  37853. */
  37854. static ThicknessTextureEnabled: boolean;
  37855. }
  37856. }
  37857. declare module BABYLON {
  37858. /** @hidden */
  37859. export var defaultFragmentDeclaration: {
  37860. name: string;
  37861. shader: string;
  37862. };
  37863. }
  37864. declare module BABYLON {
  37865. /** @hidden */
  37866. export var defaultUboDeclaration: {
  37867. name: string;
  37868. shader: string;
  37869. };
  37870. }
  37871. declare module BABYLON {
  37872. /** @hidden */
  37873. export var lightFragmentDeclaration: {
  37874. name: string;
  37875. shader: string;
  37876. };
  37877. }
  37878. declare module BABYLON {
  37879. /** @hidden */
  37880. export var lightUboDeclaration: {
  37881. name: string;
  37882. shader: string;
  37883. };
  37884. }
  37885. declare module BABYLON {
  37886. /** @hidden */
  37887. export var lightsFragmentFunctions: {
  37888. name: string;
  37889. shader: string;
  37890. };
  37891. }
  37892. declare module BABYLON {
  37893. /** @hidden */
  37894. export var shadowsFragmentFunctions: {
  37895. name: string;
  37896. shader: string;
  37897. };
  37898. }
  37899. declare module BABYLON {
  37900. /** @hidden */
  37901. export var fresnelFunction: {
  37902. name: string;
  37903. shader: string;
  37904. };
  37905. }
  37906. declare module BABYLON {
  37907. /** @hidden */
  37908. export var reflectionFunction: {
  37909. name: string;
  37910. shader: string;
  37911. };
  37912. }
  37913. declare module BABYLON {
  37914. /** @hidden */
  37915. export var bumpFragmentFunctions: {
  37916. name: string;
  37917. shader: string;
  37918. };
  37919. }
  37920. declare module BABYLON {
  37921. /** @hidden */
  37922. export var logDepthDeclaration: {
  37923. name: string;
  37924. shader: string;
  37925. };
  37926. }
  37927. declare module BABYLON {
  37928. /** @hidden */
  37929. export var bumpFragment: {
  37930. name: string;
  37931. shader: string;
  37932. };
  37933. }
  37934. declare module BABYLON {
  37935. /** @hidden */
  37936. export var depthPrePass: {
  37937. name: string;
  37938. shader: string;
  37939. };
  37940. }
  37941. declare module BABYLON {
  37942. /** @hidden */
  37943. export var lightFragment: {
  37944. name: string;
  37945. shader: string;
  37946. };
  37947. }
  37948. declare module BABYLON {
  37949. /** @hidden */
  37950. export var logDepthFragment: {
  37951. name: string;
  37952. shader: string;
  37953. };
  37954. }
  37955. declare module BABYLON {
  37956. /** @hidden */
  37957. export var defaultPixelShader: {
  37958. name: string;
  37959. shader: string;
  37960. };
  37961. }
  37962. declare module BABYLON {
  37963. /** @hidden */
  37964. export var defaultVertexDeclaration: {
  37965. name: string;
  37966. shader: string;
  37967. };
  37968. }
  37969. declare module BABYLON {
  37970. /** @hidden */
  37971. export var bumpVertexDeclaration: {
  37972. name: string;
  37973. shader: string;
  37974. };
  37975. }
  37976. declare module BABYLON {
  37977. /** @hidden */
  37978. export var bumpVertex: {
  37979. name: string;
  37980. shader: string;
  37981. };
  37982. }
  37983. declare module BABYLON {
  37984. /** @hidden */
  37985. export var fogVertex: {
  37986. name: string;
  37987. shader: string;
  37988. };
  37989. }
  37990. declare module BABYLON {
  37991. /** @hidden */
  37992. export var shadowsVertex: {
  37993. name: string;
  37994. shader: string;
  37995. };
  37996. }
  37997. declare module BABYLON {
  37998. /** @hidden */
  37999. export var pointCloudVertex: {
  38000. name: string;
  38001. shader: string;
  38002. };
  38003. }
  38004. declare module BABYLON {
  38005. /** @hidden */
  38006. export var logDepthVertex: {
  38007. name: string;
  38008. shader: string;
  38009. };
  38010. }
  38011. declare module BABYLON {
  38012. /** @hidden */
  38013. export var defaultVertexShader: {
  38014. name: string;
  38015. shader: string;
  38016. };
  38017. }
  38018. declare module BABYLON {
  38019. /** @hidden */
  38020. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  38021. MAINUV1: boolean;
  38022. MAINUV2: boolean;
  38023. DIFFUSE: boolean;
  38024. DIFFUSEDIRECTUV: number;
  38025. AMBIENT: boolean;
  38026. AMBIENTDIRECTUV: number;
  38027. OPACITY: boolean;
  38028. OPACITYDIRECTUV: number;
  38029. OPACITYRGB: boolean;
  38030. REFLECTION: boolean;
  38031. EMISSIVE: boolean;
  38032. EMISSIVEDIRECTUV: number;
  38033. SPECULAR: boolean;
  38034. SPECULARDIRECTUV: number;
  38035. BUMP: boolean;
  38036. BUMPDIRECTUV: number;
  38037. PARALLAX: boolean;
  38038. PARALLAXOCCLUSION: boolean;
  38039. SPECULAROVERALPHA: boolean;
  38040. CLIPPLANE: boolean;
  38041. CLIPPLANE2: boolean;
  38042. CLIPPLANE3: boolean;
  38043. CLIPPLANE4: boolean;
  38044. ALPHATEST: boolean;
  38045. DEPTHPREPASS: boolean;
  38046. ALPHAFROMDIFFUSE: boolean;
  38047. POINTSIZE: boolean;
  38048. FOG: boolean;
  38049. SPECULARTERM: boolean;
  38050. DIFFUSEFRESNEL: boolean;
  38051. OPACITYFRESNEL: boolean;
  38052. REFLECTIONFRESNEL: boolean;
  38053. REFRACTIONFRESNEL: boolean;
  38054. EMISSIVEFRESNEL: boolean;
  38055. FRESNEL: boolean;
  38056. NORMAL: boolean;
  38057. UV1: boolean;
  38058. UV2: boolean;
  38059. VERTEXCOLOR: boolean;
  38060. VERTEXALPHA: boolean;
  38061. NUM_BONE_INFLUENCERS: number;
  38062. BonesPerMesh: number;
  38063. BONETEXTURE: boolean;
  38064. INSTANCES: boolean;
  38065. GLOSSINESS: boolean;
  38066. ROUGHNESS: boolean;
  38067. EMISSIVEASILLUMINATION: boolean;
  38068. LINKEMISSIVEWITHDIFFUSE: boolean;
  38069. REFLECTIONFRESNELFROMSPECULAR: boolean;
  38070. LIGHTMAP: boolean;
  38071. LIGHTMAPDIRECTUV: number;
  38072. OBJECTSPACE_NORMALMAP: boolean;
  38073. USELIGHTMAPASSHADOWMAP: boolean;
  38074. REFLECTIONMAP_3D: boolean;
  38075. REFLECTIONMAP_SPHERICAL: boolean;
  38076. REFLECTIONMAP_PLANAR: boolean;
  38077. REFLECTIONMAP_CUBIC: boolean;
  38078. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  38079. REFLECTIONMAP_PROJECTION: boolean;
  38080. REFLECTIONMAP_SKYBOX: boolean;
  38081. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  38082. REFLECTIONMAP_EXPLICIT: boolean;
  38083. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  38084. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  38085. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  38086. INVERTCUBICMAP: boolean;
  38087. LOGARITHMICDEPTH: boolean;
  38088. REFRACTION: boolean;
  38089. REFRACTIONMAP_3D: boolean;
  38090. REFLECTIONOVERALPHA: boolean;
  38091. TWOSIDEDLIGHTING: boolean;
  38092. SHADOWFLOAT: boolean;
  38093. MORPHTARGETS: boolean;
  38094. MORPHTARGETS_NORMAL: boolean;
  38095. MORPHTARGETS_TANGENT: boolean;
  38096. NUM_MORPH_INFLUENCERS: number;
  38097. NONUNIFORMSCALING: boolean;
  38098. PREMULTIPLYALPHA: boolean;
  38099. IMAGEPROCESSING: boolean;
  38100. VIGNETTE: boolean;
  38101. VIGNETTEBLENDMODEMULTIPLY: boolean;
  38102. VIGNETTEBLENDMODEOPAQUE: boolean;
  38103. TONEMAPPING: boolean;
  38104. TONEMAPPING_ACES: boolean;
  38105. CONTRAST: boolean;
  38106. COLORCURVES: boolean;
  38107. COLORGRADING: boolean;
  38108. COLORGRADING3D: boolean;
  38109. SAMPLER3DGREENDEPTH: boolean;
  38110. SAMPLER3DBGRMAP: boolean;
  38111. IMAGEPROCESSINGPOSTPROCESS: boolean;
  38112. MULTIVIEW: boolean;
  38113. /**
  38114. * If the reflection texture on this material is in linear color space
  38115. * @hidden
  38116. */
  38117. IS_REFLECTION_LINEAR: boolean;
  38118. /**
  38119. * If the refraction texture on this material is in linear color space
  38120. * @hidden
  38121. */
  38122. IS_REFRACTION_LINEAR: boolean;
  38123. EXPOSURE: boolean;
  38124. constructor();
  38125. setReflectionMode(modeToEnable: string): void;
  38126. }
  38127. /**
  38128. * This is the default material used in Babylon. It is the best trade off between quality
  38129. * and performances.
  38130. * @see http://doc.babylonjs.com/babylon101/materials
  38131. */
  38132. export class StandardMaterial extends PushMaterial {
  38133. private _diffuseTexture;
  38134. /**
  38135. * The basic texture of the material as viewed under a light.
  38136. */
  38137. diffuseTexture: Nullable<BaseTexture>;
  38138. private _ambientTexture;
  38139. /**
  38140. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  38141. */
  38142. ambientTexture: Nullable<BaseTexture>;
  38143. private _opacityTexture;
  38144. /**
  38145. * Define the transparency of the material from a texture.
  38146. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  38147. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  38148. */
  38149. opacityTexture: Nullable<BaseTexture>;
  38150. private _reflectionTexture;
  38151. /**
  38152. * Define the texture used to display the reflection.
  38153. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38154. */
  38155. reflectionTexture: Nullable<BaseTexture>;
  38156. private _emissiveTexture;
  38157. /**
  38158. * Define texture of the material as if self lit.
  38159. * This will be mixed in the final result even in the absence of light.
  38160. */
  38161. emissiveTexture: Nullable<BaseTexture>;
  38162. private _specularTexture;
  38163. /**
  38164. * Define how the color and intensity of the highlight given by the light in the material.
  38165. */
  38166. specularTexture: Nullable<BaseTexture>;
  38167. private _bumpTexture;
  38168. /**
  38169. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  38170. * 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.
  38171. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  38172. */
  38173. bumpTexture: Nullable<BaseTexture>;
  38174. private _lightmapTexture;
  38175. /**
  38176. * Complex lighting can be computationally expensive to compute at runtime.
  38177. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  38178. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  38179. */
  38180. lightmapTexture: Nullable<BaseTexture>;
  38181. private _refractionTexture;
  38182. /**
  38183. * Define the texture used to display the refraction.
  38184. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38185. */
  38186. refractionTexture: Nullable<BaseTexture>;
  38187. /**
  38188. * The color of the material lit by the environmental background lighting.
  38189. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  38190. */
  38191. ambientColor: Color3;
  38192. /**
  38193. * The basic color of the material as viewed under a light.
  38194. */
  38195. diffuseColor: Color3;
  38196. /**
  38197. * Define how the color and intensity of the highlight given by the light in the material.
  38198. */
  38199. specularColor: Color3;
  38200. /**
  38201. * Define the color of the material as if self lit.
  38202. * This will be mixed in the final result even in the absence of light.
  38203. */
  38204. emissiveColor: Color3;
  38205. /**
  38206. * Defines how sharp are the highlights in the material.
  38207. * The bigger the value the sharper giving a more glossy feeling to the result.
  38208. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  38209. */
  38210. specularPower: number;
  38211. private _useAlphaFromDiffuseTexture;
  38212. /**
  38213. * Does the transparency come from the diffuse texture alpha channel.
  38214. */
  38215. useAlphaFromDiffuseTexture: boolean;
  38216. private _useEmissiveAsIllumination;
  38217. /**
  38218. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  38219. */
  38220. useEmissiveAsIllumination: boolean;
  38221. private _linkEmissiveWithDiffuse;
  38222. /**
  38223. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  38224. * the emissive level when the final color is close to one.
  38225. */
  38226. linkEmissiveWithDiffuse: boolean;
  38227. private _useSpecularOverAlpha;
  38228. /**
  38229. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  38230. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  38231. */
  38232. useSpecularOverAlpha: boolean;
  38233. private _useReflectionOverAlpha;
  38234. /**
  38235. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  38236. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  38237. */
  38238. useReflectionOverAlpha: boolean;
  38239. private _disableLighting;
  38240. /**
  38241. * Does lights from the scene impacts this material.
  38242. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  38243. */
  38244. disableLighting: boolean;
  38245. private _useObjectSpaceNormalMap;
  38246. /**
  38247. * Allows using an object space normal map (instead of tangent space).
  38248. */
  38249. useObjectSpaceNormalMap: boolean;
  38250. private _useParallax;
  38251. /**
  38252. * Is parallax enabled or not.
  38253. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38254. */
  38255. useParallax: boolean;
  38256. private _useParallaxOcclusion;
  38257. /**
  38258. * Is parallax occlusion enabled or not.
  38259. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  38260. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  38261. */
  38262. useParallaxOcclusion: boolean;
  38263. /**
  38264. * 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.
  38265. */
  38266. parallaxScaleBias: number;
  38267. private _roughness;
  38268. /**
  38269. * Helps to define how blurry the reflections should appears in the material.
  38270. */
  38271. roughness: number;
  38272. /**
  38273. * In case of refraction, define the value of the indice of refraction.
  38274. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38275. */
  38276. indexOfRefraction: number;
  38277. /**
  38278. * Invert the refraction texture alongside the y axis.
  38279. * It can be useful with procedural textures or probe for instance.
  38280. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  38281. */
  38282. invertRefractionY: boolean;
  38283. /**
  38284. * Defines the alpha limits in alpha test mode.
  38285. */
  38286. alphaCutOff: number;
  38287. private _useLightmapAsShadowmap;
  38288. /**
  38289. * In case of light mapping, define whether the map contains light or shadow informations.
  38290. */
  38291. useLightmapAsShadowmap: boolean;
  38292. private _diffuseFresnelParameters;
  38293. /**
  38294. * Define the diffuse fresnel parameters of the material.
  38295. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38296. */
  38297. diffuseFresnelParameters: FresnelParameters;
  38298. private _opacityFresnelParameters;
  38299. /**
  38300. * Define the opacity fresnel parameters of the material.
  38301. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38302. */
  38303. opacityFresnelParameters: FresnelParameters;
  38304. private _reflectionFresnelParameters;
  38305. /**
  38306. * Define the reflection fresnel parameters of the material.
  38307. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38308. */
  38309. reflectionFresnelParameters: FresnelParameters;
  38310. private _refractionFresnelParameters;
  38311. /**
  38312. * Define the refraction fresnel parameters of the material.
  38313. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38314. */
  38315. refractionFresnelParameters: FresnelParameters;
  38316. private _emissiveFresnelParameters;
  38317. /**
  38318. * Define the emissive fresnel parameters of the material.
  38319. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38320. */
  38321. emissiveFresnelParameters: FresnelParameters;
  38322. private _useReflectionFresnelFromSpecular;
  38323. /**
  38324. * If true automatically deducts the fresnels values from the material specularity.
  38325. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  38326. */
  38327. useReflectionFresnelFromSpecular: boolean;
  38328. private _useGlossinessFromSpecularMapAlpha;
  38329. /**
  38330. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  38331. */
  38332. useGlossinessFromSpecularMapAlpha: boolean;
  38333. private _maxSimultaneousLights;
  38334. /**
  38335. * Defines the maximum number of lights that can be used in the material
  38336. */
  38337. maxSimultaneousLights: number;
  38338. private _invertNormalMapX;
  38339. /**
  38340. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  38341. */
  38342. invertNormalMapX: boolean;
  38343. private _invertNormalMapY;
  38344. /**
  38345. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  38346. */
  38347. invertNormalMapY: boolean;
  38348. private _twoSidedLighting;
  38349. /**
  38350. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  38351. */
  38352. twoSidedLighting: boolean;
  38353. /**
  38354. * Default configuration related to image processing available in the standard Material.
  38355. */
  38356. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38357. /**
  38358. * Gets the image processing configuration used either in this material.
  38359. */
  38360. /**
  38361. * Sets the Default image processing configuration used either in the this material.
  38362. *
  38363. * If sets to null, the scene one is in use.
  38364. */
  38365. imageProcessingConfiguration: ImageProcessingConfiguration;
  38366. /**
  38367. * Keep track of the image processing observer to allow dispose and replace.
  38368. */
  38369. private _imageProcessingObserver;
  38370. /**
  38371. * Attaches a new image processing configuration to the Standard Material.
  38372. * @param configuration
  38373. */
  38374. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  38375. /**
  38376. * Gets wether the color curves effect is enabled.
  38377. */
  38378. /**
  38379. * Sets wether the color curves effect is enabled.
  38380. */
  38381. cameraColorCurvesEnabled: boolean;
  38382. /**
  38383. * Gets wether the color grading effect is enabled.
  38384. */
  38385. /**
  38386. * Gets wether the color grading effect is enabled.
  38387. */
  38388. cameraColorGradingEnabled: boolean;
  38389. /**
  38390. * Gets wether tonemapping is enabled or not.
  38391. */
  38392. /**
  38393. * Sets wether tonemapping is enabled or not
  38394. */
  38395. cameraToneMappingEnabled: boolean;
  38396. /**
  38397. * The camera exposure used on this material.
  38398. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38399. * This corresponds to a photographic exposure.
  38400. */
  38401. /**
  38402. * The camera exposure used on this material.
  38403. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  38404. * This corresponds to a photographic exposure.
  38405. */
  38406. cameraExposure: number;
  38407. /**
  38408. * Gets The camera contrast used on this material.
  38409. */
  38410. /**
  38411. * Sets The camera contrast used on this material.
  38412. */
  38413. cameraContrast: number;
  38414. /**
  38415. * Gets the Color Grading 2D Lookup Texture.
  38416. */
  38417. /**
  38418. * Sets the Color Grading 2D Lookup Texture.
  38419. */
  38420. cameraColorGradingTexture: Nullable<BaseTexture>;
  38421. /**
  38422. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38423. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38424. * 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;
  38425. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38426. */
  38427. /**
  38428. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  38429. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  38430. * 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;
  38431. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  38432. */
  38433. cameraColorCurves: Nullable<ColorCurves>;
  38434. /**
  38435. * Custom callback helping to override the default shader used in the material.
  38436. */
  38437. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  38438. protected _renderTargets: SmartArray<RenderTargetTexture>;
  38439. protected _worldViewProjectionMatrix: Matrix;
  38440. protected _globalAmbientColor: Color3;
  38441. protected _useLogarithmicDepth: boolean;
  38442. /**
  38443. * Instantiates a new standard material.
  38444. * This is the default material used in Babylon. It is the best trade off between quality
  38445. * and performances.
  38446. * @see http://doc.babylonjs.com/babylon101/materials
  38447. * @param name Define the name of the material in the scene
  38448. * @param scene Define the scene the material belong to
  38449. */
  38450. constructor(name: string, scene: Scene);
  38451. /**
  38452. * Gets a boolean indicating that current material needs to register RTT
  38453. */
  38454. readonly hasRenderTargetTextures: boolean;
  38455. /**
  38456. * Gets the current class name of the material e.g. "StandardMaterial"
  38457. * Mainly use in serialization.
  38458. * @returns the class name
  38459. */
  38460. getClassName(): string;
  38461. /**
  38462. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  38463. * You can try switching to logarithmic depth.
  38464. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  38465. */
  38466. useLogarithmicDepth: boolean;
  38467. /**
  38468. * Specifies if the material will require alpha blending
  38469. * @returns a boolean specifying if alpha blending is needed
  38470. */
  38471. needAlphaBlending(): boolean;
  38472. /**
  38473. * Specifies if this material should be rendered in alpha test mode
  38474. * @returns a boolean specifying if an alpha test is needed.
  38475. */
  38476. needAlphaTesting(): boolean;
  38477. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  38478. /**
  38479. * Get the texture used for alpha test purpose.
  38480. * @returns the diffuse texture in case of the standard material.
  38481. */
  38482. getAlphaTestTexture(): Nullable<BaseTexture>;
  38483. /**
  38484. * Get if the submesh is ready to be used and all its information available.
  38485. * Child classes can use it to update shaders
  38486. * @param mesh defines the mesh to check
  38487. * @param subMesh defines which submesh to check
  38488. * @param useInstances specifies that instances should be used
  38489. * @returns a boolean indicating that the submesh is ready or not
  38490. */
  38491. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  38492. /**
  38493. * Builds the material UBO layouts.
  38494. * Used internally during the effect preparation.
  38495. */
  38496. buildUniformLayout(): void;
  38497. /**
  38498. * Unbinds the material from the mesh
  38499. */
  38500. unbind(): void;
  38501. /**
  38502. * Binds the submesh to this material by preparing the effect and shader to draw
  38503. * @param world defines the world transformation matrix
  38504. * @param mesh defines the mesh containing the submesh
  38505. * @param subMesh defines the submesh to bind the material to
  38506. */
  38507. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  38508. /**
  38509. * Get the list of animatables in the material.
  38510. * @returns the list of animatables object used in the material
  38511. */
  38512. getAnimatables(): IAnimatable[];
  38513. /**
  38514. * Gets the active textures from the material
  38515. * @returns an array of textures
  38516. */
  38517. getActiveTextures(): BaseTexture[];
  38518. /**
  38519. * Specifies if the material uses a texture
  38520. * @param texture defines the texture to check against the material
  38521. * @returns a boolean specifying if the material uses the texture
  38522. */
  38523. hasTexture(texture: BaseTexture): boolean;
  38524. /**
  38525. * Disposes the material
  38526. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  38527. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  38528. */
  38529. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  38530. /**
  38531. * Makes a duplicate of the material, and gives it a new name
  38532. * @param name defines the new name for the duplicated material
  38533. * @returns the cloned material
  38534. */
  38535. clone(name: string): StandardMaterial;
  38536. /**
  38537. * Serializes this material in a JSON representation
  38538. * @returns the serialized material object
  38539. */
  38540. serialize(): any;
  38541. /**
  38542. * Creates a standard material from parsed material data
  38543. * @param source defines the JSON representation of the material
  38544. * @param scene defines the hosting scene
  38545. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  38546. * @returns a new standard material
  38547. */
  38548. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  38549. /**
  38550. * Are diffuse textures enabled in the application.
  38551. */
  38552. static DiffuseTextureEnabled: boolean;
  38553. /**
  38554. * Are ambient textures enabled in the application.
  38555. */
  38556. static AmbientTextureEnabled: boolean;
  38557. /**
  38558. * Are opacity textures enabled in the application.
  38559. */
  38560. static OpacityTextureEnabled: boolean;
  38561. /**
  38562. * Are reflection textures enabled in the application.
  38563. */
  38564. static ReflectionTextureEnabled: boolean;
  38565. /**
  38566. * Are emissive textures enabled in the application.
  38567. */
  38568. static EmissiveTextureEnabled: boolean;
  38569. /**
  38570. * Are specular textures enabled in the application.
  38571. */
  38572. static SpecularTextureEnabled: boolean;
  38573. /**
  38574. * Are bump textures enabled in the application.
  38575. */
  38576. static BumpTextureEnabled: boolean;
  38577. /**
  38578. * Are lightmap textures enabled in the application.
  38579. */
  38580. static LightmapTextureEnabled: boolean;
  38581. /**
  38582. * Are refraction textures enabled in the application.
  38583. */
  38584. static RefractionTextureEnabled: boolean;
  38585. /**
  38586. * Are color grading textures enabled in the application.
  38587. */
  38588. static ColorGradingTextureEnabled: boolean;
  38589. /**
  38590. * Are fresnels enabled in the application.
  38591. */
  38592. static FresnelEnabled: boolean;
  38593. }
  38594. }
  38595. declare module BABYLON {
  38596. /**
  38597. * A class extending Texture allowing drawing on a texture
  38598. * @see http://doc.babylonjs.com/how_to/dynamictexture
  38599. */
  38600. export class DynamicTexture extends Texture {
  38601. private _generateMipMaps;
  38602. private _canvas;
  38603. private _context;
  38604. private _engine;
  38605. /**
  38606. * Creates a DynamicTexture
  38607. * @param name defines the name of the texture
  38608. * @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
  38609. * @param scene defines the scene where you want the texture
  38610. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  38611. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  38612. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  38613. */
  38614. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  38615. /**
  38616. * Get the current class name of the texture useful for serialization or dynamic coding.
  38617. * @returns "DynamicTexture"
  38618. */
  38619. getClassName(): string;
  38620. /**
  38621. * Gets the current state of canRescale
  38622. */
  38623. readonly canRescale: boolean;
  38624. private _recreate;
  38625. /**
  38626. * Scales the texture
  38627. * @param ratio the scale factor to apply to both width and height
  38628. */
  38629. scale(ratio: number): void;
  38630. /**
  38631. * Resizes the texture
  38632. * @param width the new width
  38633. * @param height the new height
  38634. */
  38635. scaleTo(width: number, height: number): void;
  38636. /**
  38637. * Gets the context of the canvas used by the texture
  38638. * @returns the canvas context of the dynamic texture
  38639. */
  38640. getContext(): CanvasRenderingContext2D;
  38641. /**
  38642. * Clears the texture
  38643. */
  38644. clear(): void;
  38645. /**
  38646. * Updates the texture
  38647. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38648. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  38649. */
  38650. update(invertY?: boolean, premulAlpha?: boolean): void;
  38651. /**
  38652. * Draws text onto the texture
  38653. * @param text defines the text to be drawn
  38654. * @param x defines the placement of the text from the left
  38655. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  38656. * @param font defines the font to be used with font-style, font-size, font-name
  38657. * @param color defines the color used for the text
  38658. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  38659. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  38660. * @param update defines whether texture is immediately update (default is true)
  38661. */
  38662. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  38663. /**
  38664. * Clones the texture
  38665. * @returns the clone of the texture.
  38666. */
  38667. clone(): DynamicTexture;
  38668. /**
  38669. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  38670. * @returns a serialized dynamic texture object
  38671. */
  38672. serialize(): any;
  38673. /** @hidden */ private _rebuild(): void;
  38674. }
  38675. }
  38676. declare module BABYLON {
  38677. /** @hidden */
  38678. export var imageProcessingPixelShader: {
  38679. name: string;
  38680. shader: string;
  38681. };
  38682. }
  38683. declare module BABYLON {
  38684. /**
  38685. * ImageProcessingPostProcess
  38686. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  38687. */
  38688. export class ImageProcessingPostProcess extends PostProcess {
  38689. /**
  38690. * Default configuration related to image processing available in the PBR Material.
  38691. */
  38692. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  38693. /**
  38694. * Gets the image processing configuration used either in this material.
  38695. */
  38696. /**
  38697. * Sets the Default image processing configuration used either in the this material.
  38698. *
  38699. * If sets to null, the scene one is in use.
  38700. */
  38701. imageProcessingConfiguration: ImageProcessingConfiguration;
  38702. /**
  38703. * Keep track of the image processing observer to allow dispose and replace.
  38704. */
  38705. private _imageProcessingObserver;
  38706. /**
  38707. * Attaches a new image processing configuration to the PBR Material.
  38708. * @param configuration
  38709. */
  38710. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  38711. /**
  38712. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38713. */
  38714. /**
  38715. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  38716. */
  38717. colorCurves: Nullable<ColorCurves>;
  38718. /**
  38719. * Gets wether the color curves effect is enabled.
  38720. */
  38721. /**
  38722. * Sets wether the color curves effect is enabled.
  38723. */
  38724. colorCurvesEnabled: boolean;
  38725. /**
  38726. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38727. */
  38728. /**
  38729. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  38730. */
  38731. colorGradingTexture: Nullable<BaseTexture>;
  38732. /**
  38733. * Gets wether the color grading effect is enabled.
  38734. */
  38735. /**
  38736. * Gets wether the color grading effect is enabled.
  38737. */
  38738. colorGradingEnabled: boolean;
  38739. /**
  38740. * Gets exposure used in the effect.
  38741. */
  38742. /**
  38743. * Sets exposure used in the effect.
  38744. */
  38745. exposure: number;
  38746. /**
  38747. * Gets wether tonemapping is enabled or not.
  38748. */
  38749. /**
  38750. * Sets wether tonemapping is enabled or not
  38751. */
  38752. toneMappingEnabled: boolean;
  38753. /**
  38754. * Gets the type of tone mapping effect.
  38755. */
  38756. /**
  38757. * Sets the type of tone mapping effect.
  38758. */
  38759. toneMappingType: number;
  38760. /**
  38761. * Gets contrast used in the effect.
  38762. */
  38763. /**
  38764. * Sets contrast used in the effect.
  38765. */
  38766. contrast: number;
  38767. /**
  38768. * Gets Vignette stretch size.
  38769. */
  38770. /**
  38771. * Sets Vignette stretch size.
  38772. */
  38773. vignetteStretch: number;
  38774. /**
  38775. * Gets Vignette centre X Offset.
  38776. */
  38777. /**
  38778. * Sets Vignette centre X Offset.
  38779. */
  38780. vignetteCentreX: number;
  38781. /**
  38782. * Gets Vignette centre Y Offset.
  38783. */
  38784. /**
  38785. * Sets Vignette centre Y Offset.
  38786. */
  38787. vignetteCentreY: number;
  38788. /**
  38789. * Gets Vignette weight or intensity of the vignette effect.
  38790. */
  38791. /**
  38792. * Sets Vignette weight or intensity of the vignette effect.
  38793. */
  38794. vignetteWeight: number;
  38795. /**
  38796. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38797. * if vignetteEnabled is set to true.
  38798. */
  38799. /**
  38800. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  38801. * if vignetteEnabled is set to true.
  38802. */
  38803. vignetteColor: Color4;
  38804. /**
  38805. * Gets Camera field of view used by the Vignette effect.
  38806. */
  38807. /**
  38808. * Sets Camera field of view used by the Vignette effect.
  38809. */
  38810. vignetteCameraFov: number;
  38811. /**
  38812. * Gets the vignette blend mode allowing different kind of effect.
  38813. */
  38814. /**
  38815. * Sets the vignette blend mode allowing different kind of effect.
  38816. */
  38817. vignetteBlendMode: number;
  38818. /**
  38819. * Gets wether the vignette effect is enabled.
  38820. */
  38821. /**
  38822. * Sets wether the vignette effect is enabled.
  38823. */
  38824. vignetteEnabled: boolean;
  38825. private _fromLinearSpace;
  38826. /**
  38827. * Gets wether the input of the processing is in Gamma or Linear Space.
  38828. */
  38829. /**
  38830. * Sets wether the input of the processing is in Gamma or Linear Space.
  38831. */
  38832. fromLinearSpace: boolean;
  38833. /**
  38834. * Defines cache preventing GC.
  38835. */
  38836. private _defines;
  38837. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  38838. /**
  38839. * "ImageProcessingPostProcess"
  38840. * @returns "ImageProcessingPostProcess"
  38841. */
  38842. getClassName(): string;
  38843. protected _updateParameters(): void;
  38844. dispose(camera?: Camera): void;
  38845. }
  38846. }
  38847. declare module BABYLON {
  38848. /**
  38849. * Class containing static functions to help procedurally build meshes
  38850. */
  38851. export class GroundBuilder {
  38852. /**
  38853. * Creates a ground mesh
  38854. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  38855. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  38856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38857. * @param name defines the name of the mesh
  38858. * @param options defines the options used to create the mesh
  38859. * @param scene defines the hosting scene
  38860. * @returns the ground mesh
  38861. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  38862. */
  38863. static CreateGround(name: string, options: {
  38864. width?: number;
  38865. height?: number;
  38866. subdivisions?: number;
  38867. subdivisionsX?: number;
  38868. subdivisionsY?: number;
  38869. updatable?: boolean;
  38870. }, scene: any): Mesh;
  38871. /**
  38872. * Creates a tiled ground mesh
  38873. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  38874. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  38875. * * 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
  38876. * * 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
  38877. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38878. * @param name defines the name of the mesh
  38879. * @param options defines the options used to create the mesh
  38880. * @param scene defines the hosting scene
  38881. * @returns the tiled ground mesh
  38882. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  38883. */
  38884. static CreateTiledGround(name: string, options: {
  38885. xmin: number;
  38886. zmin: number;
  38887. xmax: number;
  38888. zmax: number;
  38889. subdivisions?: {
  38890. w: number;
  38891. h: number;
  38892. };
  38893. precision?: {
  38894. w: number;
  38895. h: number;
  38896. };
  38897. updatable?: boolean;
  38898. }, scene?: Nullable<Scene>): Mesh;
  38899. /**
  38900. * Creates a ground mesh from a height map
  38901. * * The parameter `url` sets the URL of the height map image resource.
  38902. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  38903. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  38904. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  38905. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  38906. * * 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.
  38907. * * 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).
  38908. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  38909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38910. * @param name defines the name of the mesh
  38911. * @param url defines the url to the height map
  38912. * @param options defines the options used to create the mesh
  38913. * @param scene defines the hosting scene
  38914. * @returns the ground mesh
  38915. * @see https://doc.babylonjs.com/babylon101/height_map
  38916. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  38917. */
  38918. static CreateGroundFromHeightMap(name: string, url: string, options: {
  38919. width?: number;
  38920. height?: number;
  38921. subdivisions?: number;
  38922. minHeight?: number;
  38923. maxHeight?: number;
  38924. colorFilter?: Color3;
  38925. alphaFilter?: number;
  38926. updatable?: boolean;
  38927. onReady?: (mesh: GroundMesh) => void;
  38928. }, scene?: Nullable<Scene>): GroundMesh;
  38929. }
  38930. }
  38931. declare module BABYLON {
  38932. /**
  38933. * Class containing static functions to help procedurally build meshes
  38934. */
  38935. export class TorusBuilder {
  38936. /**
  38937. * Creates a torus mesh
  38938. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  38939. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  38940. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  38941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38942. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38943. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38944. * @param name defines the name of the mesh
  38945. * @param options defines the options used to create the mesh
  38946. * @param scene defines the hosting scene
  38947. * @returns the torus mesh
  38948. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  38949. */
  38950. static CreateTorus(name: string, options: {
  38951. diameter?: number;
  38952. thickness?: number;
  38953. tessellation?: number;
  38954. updatable?: boolean;
  38955. sideOrientation?: number;
  38956. frontUVs?: Vector4;
  38957. backUVs?: Vector4;
  38958. }, scene: any): Mesh;
  38959. }
  38960. }
  38961. declare module BABYLON {
  38962. /**
  38963. * Class containing static functions to help procedurally build meshes
  38964. */
  38965. export class CylinderBuilder {
  38966. /**
  38967. * Creates a cylinder or a cone mesh
  38968. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  38969. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  38970. * * 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.
  38971. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  38972. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  38973. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  38974. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  38975. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  38976. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  38977. * * 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).
  38978. * * 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
  38979. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  38980. * * 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
  38981. * * 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.
  38982. * * If `enclose` is false, a ring surface is one element.
  38983. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  38984. * * 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
  38985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38987. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  38988. * @param name defines the name of the mesh
  38989. * @param options defines the options used to create the mesh
  38990. * @param scene defines the hosting scene
  38991. * @returns the cylinder mesh
  38992. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  38993. */
  38994. static CreateCylinder(name: string, options: {
  38995. height?: number;
  38996. diameterTop?: number;
  38997. diameterBottom?: number;
  38998. diameter?: number;
  38999. tessellation?: number;
  39000. subdivisions?: number;
  39001. arc?: number;
  39002. faceColors?: Color4[];
  39003. faceUV?: Vector4[];
  39004. updatable?: boolean;
  39005. hasRings?: boolean;
  39006. enclose?: boolean;
  39007. cap?: number;
  39008. sideOrientation?: number;
  39009. frontUVs?: Vector4;
  39010. backUVs?: Vector4;
  39011. }, scene: any): Mesh;
  39012. }
  39013. }
  39014. declare module BABYLON {
  39015. /**
  39016. * Options to modify the vr teleportation behavior.
  39017. */
  39018. export interface VRTeleportationOptions {
  39019. /**
  39020. * The name of the mesh which should be used as the teleportation floor. (default: null)
  39021. */
  39022. floorMeshName?: string;
  39023. /**
  39024. * A list of meshes to be used as the teleportation floor. (default: empty)
  39025. */
  39026. floorMeshes?: Mesh[];
  39027. }
  39028. /**
  39029. * Options to modify the vr experience helper's behavior.
  39030. */
  39031. export interface VRExperienceHelperOptions extends WebVROptions {
  39032. /**
  39033. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  39034. */
  39035. createDeviceOrientationCamera?: boolean;
  39036. /**
  39037. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  39038. */
  39039. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  39040. /**
  39041. * Uses the main button on the controller to toggle the laser casted. (default: true)
  39042. */
  39043. laserToggle?: boolean;
  39044. /**
  39045. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  39046. */
  39047. floorMeshes?: Mesh[];
  39048. /**
  39049. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  39050. */
  39051. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  39052. }
  39053. /**
  39054. * Event containing information after VR has been entered
  39055. */
  39056. export class OnAfterEnteringVRObservableEvent {
  39057. /**
  39058. * If entering vr was successful
  39059. */
  39060. success: boolean;
  39061. }
  39062. /**
  39063. * Helps to quickly add VR support to an existing scene.
  39064. * See http://doc.babylonjs.com/how_to/webvr_helper
  39065. */
  39066. export class VRExperienceHelper {
  39067. /** Options to modify the vr experience helper's behavior. */
  39068. webVROptions: VRExperienceHelperOptions;
  39069. private _scene;
  39070. private _position;
  39071. private _btnVR;
  39072. private _btnVRDisplayed;
  39073. private _webVRsupported;
  39074. private _webVRready;
  39075. private _webVRrequesting;
  39076. private _webVRpresenting;
  39077. private _hasEnteredVR;
  39078. private _fullscreenVRpresenting;
  39079. private _canvas;
  39080. private _webVRCamera;
  39081. private _vrDeviceOrientationCamera;
  39082. private _deviceOrientationCamera;
  39083. private _existingCamera;
  39084. private _onKeyDown;
  39085. private _onVrDisplayPresentChange;
  39086. private _onVRDisplayChanged;
  39087. private _onVRRequestPresentStart;
  39088. private _onVRRequestPresentComplete;
  39089. /**
  39090. * Observable raised right before entering VR.
  39091. */
  39092. onEnteringVRObservable: Observable<VRExperienceHelper>;
  39093. /**
  39094. * Observable raised when entering VR has completed.
  39095. */
  39096. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  39097. /**
  39098. * Observable raised when exiting VR.
  39099. */
  39100. onExitingVRObservable: Observable<VRExperienceHelper>;
  39101. /**
  39102. * Observable raised when controller mesh is loaded.
  39103. */
  39104. onControllerMeshLoadedObservable: Observable<WebVRController>;
  39105. /** Return this.onEnteringVRObservable
  39106. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  39107. */
  39108. readonly onEnteringVR: Observable<VRExperienceHelper>;
  39109. /** Return this.onExitingVRObservable
  39110. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  39111. */
  39112. readonly onExitingVR: Observable<VRExperienceHelper>;
  39113. /** Return this.onControllerMeshLoadedObservable
  39114. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  39115. */
  39116. readonly onControllerMeshLoaded: Observable<WebVRController>;
  39117. private _rayLength;
  39118. private _useCustomVRButton;
  39119. private _teleportationRequested;
  39120. private _teleportActive;
  39121. private _floorMeshName;
  39122. private _floorMeshesCollection;
  39123. private _rotationAllowed;
  39124. private _teleportBackwardsVector;
  39125. private _teleportationTarget;
  39126. private _isDefaultTeleportationTarget;
  39127. private _postProcessMove;
  39128. private _teleportationFillColor;
  39129. private _teleportationBorderColor;
  39130. private _rotationAngle;
  39131. private _haloCenter;
  39132. private _cameraGazer;
  39133. private _padSensibilityUp;
  39134. private _padSensibilityDown;
  39135. private _leftController;
  39136. private _rightController;
  39137. /**
  39138. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  39139. */
  39140. onNewMeshSelected: Observable<AbstractMesh>;
  39141. /**
  39142. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  39143. */
  39144. onNewMeshPicked: Observable<PickingInfo>;
  39145. private _circleEase;
  39146. /**
  39147. * Observable raised before camera teleportation
  39148. */
  39149. onBeforeCameraTeleport: Observable<Vector3>;
  39150. /**
  39151. * Observable raised after camera teleportation
  39152. */
  39153. onAfterCameraTeleport: Observable<Vector3>;
  39154. /**
  39155. * Observable raised when current selected mesh gets unselected
  39156. */
  39157. onSelectedMeshUnselected: Observable<AbstractMesh>;
  39158. private _raySelectionPredicate;
  39159. /**
  39160. * To be optionaly changed by user to define custom ray selection
  39161. */
  39162. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  39163. /**
  39164. * To be optionaly changed by user to define custom selection logic (after ray selection)
  39165. */
  39166. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  39167. /**
  39168. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  39169. */
  39170. teleportationEnabled: boolean;
  39171. private _defaultHeight;
  39172. private _teleportationInitialized;
  39173. private _interactionsEnabled;
  39174. private _interactionsRequested;
  39175. private _displayGaze;
  39176. private _displayLaserPointer;
  39177. /**
  39178. * The mesh used to display where the user is going to teleport.
  39179. */
  39180. /**
  39181. * Sets the mesh to be used to display where the user is going to teleport.
  39182. */
  39183. teleportationTarget: Mesh;
  39184. /**
  39185. * 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
  39186. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  39187. * See http://doc.babylonjs.com/resources/baking_transformations
  39188. */
  39189. gazeTrackerMesh: Mesh;
  39190. /**
  39191. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  39192. */
  39193. updateGazeTrackerScale: boolean;
  39194. /**
  39195. * If the gaze trackers color should be updated when selecting meshes
  39196. */
  39197. updateGazeTrackerColor: boolean;
  39198. /**
  39199. * The gaze tracking mesh corresponding to the left controller
  39200. */
  39201. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  39202. /**
  39203. * The gaze tracking mesh corresponding to the right controller
  39204. */
  39205. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  39206. /**
  39207. * If the ray of the gaze should be displayed.
  39208. */
  39209. /**
  39210. * Sets if the ray of the gaze should be displayed.
  39211. */
  39212. displayGaze: boolean;
  39213. /**
  39214. * If the ray of the LaserPointer should be displayed.
  39215. */
  39216. /**
  39217. * Sets if the ray of the LaserPointer should be displayed.
  39218. */
  39219. displayLaserPointer: boolean;
  39220. /**
  39221. * The deviceOrientationCamera used as the camera when not in VR.
  39222. */
  39223. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  39224. /**
  39225. * Based on the current WebVR support, returns the current VR camera used.
  39226. */
  39227. readonly currentVRCamera: Nullable<Camera>;
  39228. /**
  39229. * The webVRCamera which is used when in VR.
  39230. */
  39231. readonly webVRCamera: WebVRFreeCamera;
  39232. /**
  39233. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  39234. */
  39235. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  39236. private readonly _teleportationRequestInitiated;
  39237. /**
  39238. * Defines wether or not Pointer lock should be requested when switching to
  39239. * full screen.
  39240. */
  39241. requestPointerLockOnFullScreen: boolean;
  39242. /**
  39243. * Instantiates a VRExperienceHelper.
  39244. * Helps to quickly add VR support to an existing scene.
  39245. * @param scene The scene the VRExperienceHelper belongs to.
  39246. * @param webVROptions Options to modify the vr experience helper's behavior.
  39247. */
  39248. constructor(scene: Scene,
  39249. /** Options to modify the vr experience helper's behavior. */
  39250. webVROptions?: VRExperienceHelperOptions);
  39251. private _onDefaultMeshLoaded;
  39252. private _onResize;
  39253. private _onFullscreenChange;
  39254. /**
  39255. * Gets a value indicating if we are currently in VR mode.
  39256. */
  39257. readonly isInVRMode: boolean;
  39258. private onVrDisplayPresentChange;
  39259. private onVRDisplayChanged;
  39260. private moveButtonToBottomRight;
  39261. private displayVRButton;
  39262. private updateButtonVisibility;
  39263. private _cachedAngularSensibility;
  39264. /**
  39265. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  39266. * Otherwise, will use the fullscreen API.
  39267. */
  39268. enterVR(): void;
  39269. /**
  39270. * Attempt to exit VR, or fullscreen.
  39271. */
  39272. exitVR(): void;
  39273. /**
  39274. * The position of the vr experience helper.
  39275. */
  39276. /**
  39277. * Sets the position of the vr experience helper.
  39278. */
  39279. position: Vector3;
  39280. /**
  39281. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  39282. */
  39283. enableInteractions(): void;
  39284. private readonly _noControllerIsActive;
  39285. private beforeRender;
  39286. private _isTeleportationFloor;
  39287. /**
  39288. * Adds a floor mesh to be used for teleportation.
  39289. * @param floorMesh the mesh to be used for teleportation.
  39290. */
  39291. addFloorMesh(floorMesh: Mesh): void;
  39292. /**
  39293. * Removes a floor mesh from being used for teleportation.
  39294. * @param floorMesh the mesh to be removed.
  39295. */
  39296. removeFloorMesh(floorMesh: Mesh): void;
  39297. /**
  39298. * Enables interactions and teleportation using the VR controllers and gaze.
  39299. * @param vrTeleportationOptions options to modify teleportation behavior.
  39300. */
  39301. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  39302. private _onNewGamepadConnected;
  39303. private _tryEnableInteractionOnController;
  39304. private _onNewGamepadDisconnected;
  39305. private _enableInteractionOnController;
  39306. private _checkTeleportWithRay;
  39307. private _checkRotate;
  39308. private _checkTeleportBackwards;
  39309. private _enableTeleportationOnController;
  39310. private _createTeleportationCircles;
  39311. private _displayTeleportationTarget;
  39312. private _hideTeleportationTarget;
  39313. private _rotateCamera;
  39314. private _moveTeleportationSelectorTo;
  39315. private _workingVector;
  39316. private _workingQuaternion;
  39317. private _workingMatrix;
  39318. /**
  39319. * Teleports the users feet to the desired location
  39320. * @param location The location where the user's feet should be placed
  39321. */
  39322. teleportCamera(location: Vector3): void;
  39323. private _convertNormalToDirectionOfRay;
  39324. private _castRayAndSelectObject;
  39325. private _notifySelectedMeshUnselected;
  39326. /**
  39327. * Sets the color of the laser ray from the vr controllers.
  39328. * @param color new color for the ray.
  39329. */
  39330. changeLaserColor(color: Color3): void;
  39331. /**
  39332. * Sets the color of the ray from the vr headsets gaze.
  39333. * @param color new color for the ray.
  39334. */
  39335. changeGazeColor(color: Color3): void;
  39336. /**
  39337. * Exits VR and disposes of the vr experience helper
  39338. */
  39339. dispose(): void;
  39340. /**
  39341. * Gets the name of the VRExperienceHelper class
  39342. * @returns "VRExperienceHelper"
  39343. */
  39344. getClassName(): string;
  39345. }
  39346. }
  39347. declare module BABYLON {
  39348. /**
  39349. * Manages an XRSession
  39350. * @see https://doc.babylonjs.com/how_to/webxr
  39351. */
  39352. export class WebXRSessionManager implements IDisposable {
  39353. private scene;
  39354. /**
  39355. * Fires every time a new xrFrame arrives which can be used to update the camera
  39356. */
  39357. onXRFrameObservable: Observable<any>;
  39358. /**
  39359. * Fires when the xr session is ended either by the device or manually done
  39360. */
  39361. onXRSessionEnded: Observable<any>;
  39362. /** @hidden */ private _xrSession: XRSession;
  39363. /** @hidden */ private _frameOfReference: XRFrameOfReference;
  39364. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  39365. /** @hidden */ private _currentXRFrame: Nullable<XRFrame>;
  39366. private _xrNavigator;
  39367. private _xrDevice;
  39368. private _tmpMatrix;
  39369. /**
  39370. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  39371. * @param scene The scene which the session should be created for
  39372. */
  39373. constructor(scene: Scene);
  39374. /**
  39375. * Initializes the manager
  39376. * After initialization enterXR can be called to start an XR session
  39377. * @returns Promise which resolves after it is initialized
  39378. */
  39379. initializeAsync(): Promise<void>;
  39380. /**
  39381. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  39382. * @param sessionCreationOptions xr options to create the session with
  39383. * @param frameOfReferenceType option to configure how the xr pose is expressed
  39384. * @returns Promise which resolves after it enters XR
  39385. */
  39386. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  39387. /**
  39388. * Stops the xrSession and restores the renderloop
  39389. * @returns Promise which resolves after it exits XR
  39390. */
  39391. exitXRAsync(): Promise<void>;
  39392. /**
  39393. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39394. * @param ray ray to cast into the environment
  39395. * @returns Promise which resolves with a collision point in the environment if it exists
  39396. */
  39397. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39398. /**
  39399. * Checks if a session would be supported for the creation options specified
  39400. * @param options creation options to check if they are supported
  39401. * @returns true if supported
  39402. */
  39403. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39404. /**
  39405. * @hidden
  39406. * Converts the render layer of xrSession to a render target
  39407. * @param session session to create render target for
  39408. * @param scene scene the new render target should be created for
  39409. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  39410. /**
  39411. * Disposes of the session manager
  39412. */
  39413. dispose(): void;
  39414. }
  39415. }
  39416. declare module BABYLON {
  39417. /**
  39418. * WebXR Camera which holds the views for the xrSession
  39419. * @see https://doc.babylonjs.com/how_to/webxr
  39420. */
  39421. export class WebXRCamera extends FreeCamera {
  39422. private static _TmpMatrix;
  39423. /**
  39424. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  39425. * @param name the name of the camera
  39426. * @param scene the scene to add the camera to
  39427. */
  39428. constructor(name: string, scene: Scene);
  39429. private _updateNumberOfRigCameras;
  39430. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  39431. /**
  39432. * Updates the cameras position from the current pose information of the XR session
  39433. * @param xrSessionManager the session containing pose information
  39434. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  39435. */
  39436. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  39437. }
  39438. }
  39439. declare module BABYLON {
  39440. /**
  39441. * States of the webXR experience
  39442. */
  39443. export enum WebXRState {
  39444. /**
  39445. * Transitioning to being in XR mode
  39446. */
  39447. ENTERING_XR = 0,
  39448. /**
  39449. * Transitioning to non XR mode
  39450. */
  39451. EXITING_XR = 1,
  39452. /**
  39453. * In XR mode and presenting
  39454. */
  39455. IN_XR = 2,
  39456. /**
  39457. * Not entered XR mode
  39458. */
  39459. NOT_IN_XR = 3
  39460. }
  39461. /**
  39462. * Helper class used to enable XR
  39463. * @see https://doc.babylonjs.com/how_to/webxr
  39464. */
  39465. export class WebXRExperienceHelper implements IDisposable {
  39466. private scene;
  39467. /**
  39468. * 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
  39469. */
  39470. container: AbstractMesh;
  39471. /**
  39472. * Camera used to render xr content
  39473. */
  39474. camera: WebXRCamera;
  39475. /**
  39476. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  39477. */
  39478. state: WebXRState;
  39479. private _setState;
  39480. private static _TmpVector;
  39481. /**
  39482. * Fires when the state of the experience helper has changed
  39483. */
  39484. onStateChangedObservable: Observable<WebXRState>;
  39485. /** @hidden */ private _sessionManager: WebXRSessionManager;
  39486. private _nonVRCamera;
  39487. private _originalSceneAutoClear;
  39488. private _supported;
  39489. /**
  39490. * Creates the experience helper
  39491. * @param scene the scene to attach the experience helper to
  39492. * @returns a promise for the experience helper
  39493. */
  39494. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  39495. /**
  39496. * Creates a WebXRExperienceHelper
  39497. * @param scene The scene the helper should be created in
  39498. */
  39499. private constructor();
  39500. /**
  39501. * Exits XR mode and returns the scene to its original state
  39502. * @returns promise that resolves after xr mode has exited
  39503. */
  39504. exitXRAsync(): Promise<void>;
  39505. /**
  39506. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  39507. * @param sessionCreationOptions options for the XR session
  39508. * @param frameOfReference frame of reference of the XR session
  39509. * @returns promise that resolves after xr mode has entered
  39510. */
  39511. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  39512. /**
  39513. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  39514. * @param ray ray to cast into the environment
  39515. * @returns Promise which resolves with a collision point in the environment if it exists
  39516. */
  39517. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  39518. /**
  39519. * Updates the global position of the camera by moving the camera's container
  39520. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  39521. * @param position The desired global position of the camera
  39522. */
  39523. setPositionOfCameraUsingContainer(position: Vector3): void;
  39524. /**
  39525. * Rotates the xr camera by rotating the camera's container around the camera's position
  39526. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  39527. * @param rotation the desired quaternion rotation to apply to the camera
  39528. */
  39529. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  39530. /**
  39531. * Checks if the creation options are supported by the xr session
  39532. * @param options creation options
  39533. * @returns true if supported
  39534. */
  39535. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  39536. /**
  39537. * Disposes of the experience helper
  39538. */
  39539. dispose(): void;
  39540. }
  39541. }
  39542. declare module BABYLON {
  39543. /**
  39544. * Button which can be used to enter a different mode of XR
  39545. */
  39546. export class WebXREnterExitUIButton {
  39547. /** button element */
  39548. element: HTMLElement;
  39549. /** XR initialization options for the button */
  39550. initializationOptions: XRSessionCreationOptions;
  39551. /**
  39552. * Creates a WebXREnterExitUIButton
  39553. * @param element button element
  39554. * @param initializationOptions XR initialization options for the button
  39555. */
  39556. constructor(
  39557. /** button element */
  39558. element: HTMLElement,
  39559. /** XR initialization options for the button */
  39560. initializationOptions: XRSessionCreationOptions);
  39561. /**
  39562. * Overwritable function which can be used to update the button's visuals when the state changes
  39563. * @param activeButton the current active button in the UI
  39564. */
  39565. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  39566. }
  39567. /**
  39568. * Options to create the webXR UI
  39569. */
  39570. export class WebXREnterExitUIOptions {
  39571. /**
  39572. * Context to enter xr with
  39573. */
  39574. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  39575. /**
  39576. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  39577. */
  39578. customButtons?: Array<WebXREnterExitUIButton>;
  39579. }
  39580. /**
  39581. * UI to allow the user to enter/exit XR mode
  39582. */
  39583. export class WebXREnterExitUI implements IDisposable {
  39584. private scene;
  39585. private _overlay;
  39586. private _buttons;
  39587. private _activeButton;
  39588. /**
  39589. * Fired every time the active button is changed.
  39590. *
  39591. * When xr is entered via a button that launches xr that button will be the callback parameter
  39592. *
  39593. * When exiting xr the callback parameter will be null)
  39594. */
  39595. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  39596. /**
  39597. * Creates UI to allow the user to enter/exit XR mode
  39598. * @param scene the scene to add the ui to
  39599. * @param helper the xr experience helper to enter/exit xr with
  39600. * @param options options to configure the UI
  39601. * @returns the created ui
  39602. */
  39603. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  39604. private constructor();
  39605. private _updateButtons;
  39606. /**
  39607. * Disposes of the object
  39608. */
  39609. dispose(): void;
  39610. }
  39611. }
  39612. declare module BABYLON {
  39613. /**
  39614. * Represents an XR input
  39615. */
  39616. export class WebXRController {
  39617. /**
  39618. * 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
  39619. */
  39620. grip?: AbstractMesh;
  39621. /**
  39622. * Pointer which can be used to select objects or attach a visible laser to
  39623. */
  39624. pointer: AbstractMesh;
  39625. /**
  39626. * Creates the controller
  39627. * @see https://doc.babylonjs.com/how_to/webxr
  39628. * @param scene the scene which the controller should be associated to
  39629. */
  39630. constructor(scene: Scene);
  39631. /**
  39632. * Disposes of the object
  39633. */
  39634. dispose(): void;
  39635. }
  39636. /**
  39637. * XR input used to track XR inputs such as controllers/rays
  39638. */
  39639. export class WebXRInput implements IDisposable {
  39640. private helper;
  39641. /**
  39642. * XR controllers being tracked
  39643. */
  39644. controllers: Array<WebXRController>;
  39645. private _tmpMatrix;
  39646. private _frameObserver;
  39647. /**
  39648. * Initializes the WebXRInput
  39649. * @param helper experience helper which the input should be created for
  39650. */
  39651. constructor(helper: WebXRExperienceHelper);
  39652. /**
  39653. * Disposes of the object
  39654. */
  39655. dispose(): void;
  39656. }
  39657. }
  39658. declare module BABYLON {
  39659. /**
  39660. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  39661. */
  39662. export class WebXRManagedOutputCanvas implements IDisposable {
  39663. private _canvas;
  39664. /**
  39665. * xrpresent context of the canvas which can be used to display/mirror xr content
  39666. */
  39667. canvasContext: Nullable<WebGLRenderingContext>;
  39668. /**
  39669. * Initializes the canvas to be added/removed upon entering/exiting xr
  39670. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  39671. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  39672. */
  39673. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  39674. /**
  39675. * Disposes of the object
  39676. */
  39677. dispose(): void;
  39678. private _setManagedOutputCanvas;
  39679. private _addCanvas;
  39680. private _removeCanvas;
  39681. }
  39682. }
  39683. declare module BABYLON {
  39684. /**
  39685. * Contains an array of blocks representing the octree
  39686. */
  39687. export interface IOctreeContainer<T> {
  39688. /**
  39689. * Blocks within the octree
  39690. */
  39691. blocks: Array<OctreeBlock<T>>;
  39692. }
  39693. /**
  39694. * Class used to store a cell in an octree
  39695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39696. */
  39697. export class OctreeBlock<T> {
  39698. /**
  39699. * Gets the content of the current block
  39700. */
  39701. entries: T[];
  39702. /**
  39703. * Gets the list of block children
  39704. */
  39705. blocks: Array<OctreeBlock<T>>;
  39706. private _depth;
  39707. private _maxDepth;
  39708. private _capacity;
  39709. private _minPoint;
  39710. private _maxPoint;
  39711. private _boundingVectors;
  39712. private _creationFunc;
  39713. /**
  39714. * Creates a new block
  39715. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  39716. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  39717. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39718. * @param depth defines the current depth of this block in the octree
  39719. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  39720. * @param creationFunc defines a callback to call when an element is added to the block
  39721. */
  39722. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  39723. /**
  39724. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  39725. */
  39726. readonly capacity: number;
  39727. /**
  39728. * Gets the minimum vector (in world space) of the block's bounding box
  39729. */
  39730. readonly minPoint: Vector3;
  39731. /**
  39732. * Gets the maximum vector (in world space) of the block's bounding box
  39733. */
  39734. readonly maxPoint: Vector3;
  39735. /**
  39736. * Add a new element to this block
  39737. * @param entry defines the element to add
  39738. */
  39739. addEntry(entry: T): void;
  39740. /**
  39741. * Remove an element from this block
  39742. * @param entry defines the element to remove
  39743. */
  39744. removeEntry(entry: T): void;
  39745. /**
  39746. * Add an array of elements to this block
  39747. * @param entries defines the array of elements to add
  39748. */
  39749. addEntries(entries: T[]): void;
  39750. /**
  39751. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  39752. * @param frustumPlanes defines the frustum planes to test
  39753. * @param selection defines the array to store current content if selection is positive
  39754. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39755. */
  39756. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39757. /**
  39758. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  39759. * @param sphereCenter defines the bounding sphere center
  39760. * @param sphereRadius defines the bounding sphere radius
  39761. * @param selection defines the array to store current content if selection is positive
  39762. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39763. */
  39764. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  39765. /**
  39766. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  39767. * @param ray defines the ray to test with
  39768. * @param selection defines the array to store current content if selection is positive
  39769. */
  39770. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  39771. /**
  39772. * Subdivide the content into child blocks (this block will then be empty)
  39773. */
  39774. createInnerBlocks(): void;
  39775. /**
  39776. * @hidden
  39777. */ 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;
  39778. }
  39779. }
  39780. declare module BABYLON {
  39781. /**
  39782. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  39783. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39784. */
  39785. export class Octree<T> {
  39786. /** 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.) */
  39787. maxDepth: number;
  39788. /**
  39789. * Blocks within the octree containing objects
  39790. */
  39791. blocks: Array<OctreeBlock<T>>;
  39792. /**
  39793. * Content stored in the octree
  39794. */
  39795. dynamicContent: T[];
  39796. private _maxBlockCapacity;
  39797. private _selectionContent;
  39798. private _creationFunc;
  39799. /**
  39800. * Creates a octree
  39801. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39802. * @param creationFunc function to be used to instatiate the octree
  39803. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  39804. * @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.)
  39805. */
  39806. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  39807. /** 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.) */
  39808. maxDepth?: number);
  39809. /**
  39810. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  39811. * @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);
  39812. * @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);
  39813. * @param entries meshes to be added to the octree blocks
  39814. */
  39815. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  39816. /**
  39817. * Adds a mesh to the octree
  39818. * @param entry Mesh to add to the octree
  39819. */
  39820. addMesh(entry: T): void;
  39821. /**
  39822. * Remove an element from the octree
  39823. * @param entry defines the element to remove
  39824. */
  39825. removeMesh(entry: T): void;
  39826. /**
  39827. * Selects an array of meshes within the frustum
  39828. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  39829. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  39830. * @returns array of meshes within the frustum
  39831. */
  39832. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  39833. /**
  39834. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  39835. * @param sphereCenter defines the bounding sphere center
  39836. * @param sphereRadius defines the bounding sphere radius
  39837. * @param allowDuplicate defines if the selection array can contains duplicated entries
  39838. * @returns an array of objects that intersect the sphere
  39839. */
  39840. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  39841. /**
  39842. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  39843. * @param ray defines the ray to test with
  39844. * @returns array of intersected objects
  39845. */
  39846. intersectsRay(ray: Ray): SmartArray<T>;
  39847. /**
  39848. * Adds a mesh into the octree block if it intersects the block
  39849. */
  39850. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  39851. /**
  39852. * Adds a submesh into the octree block if it intersects the block
  39853. */
  39854. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  39855. }
  39856. }
  39857. declare module BABYLON {
  39858. interface Scene {
  39859. /**
  39860. * @hidden
  39861. * Backing Filed
  39862. */ private _selectionOctree: Octree<AbstractMesh>;
  39863. /**
  39864. * Gets the octree used to boost mesh selection (picking)
  39865. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39866. */
  39867. selectionOctree: Octree<AbstractMesh>;
  39868. /**
  39869. * Creates or updates the octree used to boost selection (picking)
  39870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39871. * @param maxCapacity defines the maximum capacity per leaf
  39872. * @param maxDepth defines the maximum depth of the octree
  39873. * @returns an octree of AbstractMesh
  39874. */
  39875. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  39876. }
  39877. interface AbstractMesh {
  39878. /**
  39879. * @hidden
  39880. * Backing Field
  39881. */ private _submeshesOctree: Octree<SubMesh>;
  39882. /**
  39883. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  39884. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  39885. * @param maxCapacity defines the maximum size of each block (64 by default)
  39886. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  39887. * @returns the new octree
  39888. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  39889. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  39890. */
  39891. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  39892. }
  39893. /**
  39894. * Defines the octree scene component responsible to manage any octrees
  39895. * in a given scene.
  39896. */
  39897. export class OctreeSceneComponent {
  39898. /**
  39899. * The component name help to identify the component in the list of scene components.
  39900. */
  39901. readonly name: string;
  39902. /**
  39903. * The scene the component belongs to.
  39904. */
  39905. scene: Scene;
  39906. /**
  39907. * Indicates if the meshes have been checked to make sure they are isEnabled()
  39908. */
  39909. readonly checksIsEnabled: boolean;
  39910. /**
  39911. * Creates a new instance of the component for the given scene
  39912. * @param scene Defines the scene to register the component in
  39913. */
  39914. constructor(scene: Scene);
  39915. /**
  39916. * Registers the component in a given scene
  39917. */
  39918. register(): void;
  39919. /**
  39920. * Return the list of active meshes
  39921. * @returns the list of active meshes
  39922. */
  39923. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  39924. /**
  39925. * Return the list of active sub meshes
  39926. * @param mesh The mesh to get the candidates sub meshes from
  39927. * @returns the list of active sub meshes
  39928. */
  39929. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  39930. private _tempRay;
  39931. /**
  39932. * Return the list of sub meshes intersecting with a given local ray
  39933. * @param mesh defines the mesh to find the submesh for
  39934. * @param localRay defines the ray in local space
  39935. * @returns the list of intersecting sub meshes
  39936. */
  39937. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  39938. /**
  39939. * Return the list of sub meshes colliding with a collider
  39940. * @param mesh defines the mesh to find the submesh for
  39941. * @param collider defines the collider to evaluate the collision against
  39942. * @returns the list of colliding sub meshes
  39943. */
  39944. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  39945. /**
  39946. * Rebuilds the elements related to this component in case of
  39947. * context lost for instance.
  39948. */
  39949. rebuild(): void;
  39950. /**
  39951. * Disposes the component and the associated ressources.
  39952. */
  39953. dispose(): void;
  39954. }
  39955. }
  39956. declare module BABYLON {
  39957. /**
  39958. * Renders a layer on top of an existing scene
  39959. */
  39960. export class UtilityLayerRenderer implements IDisposable {
  39961. /** the original scene that will be rendered on top of */
  39962. originalScene: Scene;
  39963. private _pointerCaptures;
  39964. private _lastPointerEvents;
  39965. private static _DefaultUtilityLayer;
  39966. private static _DefaultKeepDepthUtilityLayer;
  39967. private _sharedGizmoLight;
  39968. /**
  39969. * @hidden
  39970. * Light which used by gizmos to get light shading
  39971. */ private _getSharedGizmoLight(): HemisphericLight;
  39972. /**
  39973. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  39974. */
  39975. pickUtilitySceneFirst: boolean;
  39976. /**
  39977. * 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)
  39978. */
  39979. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  39980. /**
  39981. * 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)
  39982. */
  39983. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  39984. /**
  39985. * The scene that is rendered on top of the original scene
  39986. */
  39987. utilityLayerScene: Scene;
  39988. /**
  39989. * If the utility layer should automatically be rendered on top of existing scene
  39990. */
  39991. shouldRender: boolean;
  39992. /**
  39993. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  39994. */
  39995. onlyCheckPointerDownEvents: boolean;
  39996. /**
  39997. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  39998. */
  39999. processAllEvents: boolean;
  40000. /**
  40001. * Observable raised when the pointer move from the utility layer scene to the main scene
  40002. */
  40003. onPointerOutObservable: Observable<number>;
  40004. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  40005. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  40006. private _afterRenderObserver;
  40007. private _sceneDisposeObserver;
  40008. private _originalPointerObserver;
  40009. /**
  40010. * Instantiates a UtilityLayerRenderer
  40011. * @param originalScene the original scene that will be rendered on top of
  40012. * @param handleEvents boolean indicating if the utility layer should handle events
  40013. */
  40014. constructor(
  40015. /** the original scene that will be rendered on top of */
  40016. originalScene: Scene, handleEvents?: boolean);
  40017. private _notifyObservers;
  40018. /**
  40019. * Renders the utility layers scene on top of the original scene
  40020. */
  40021. render(): void;
  40022. /**
  40023. * Disposes of the renderer
  40024. */
  40025. dispose(): void;
  40026. private _updateCamera;
  40027. }
  40028. }
  40029. declare module BABYLON {
  40030. /**
  40031. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  40032. */
  40033. export class Gizmo implements IDisposable {
  40034. /** The utility layer the gizmo will be added to */
  40035. gizmoLayer: UtilityLayerRenderer;
  40036. /**
  40037. * The root mesh of the gizmo
  40038. */ private _rootMesh: Mesh;
  40039. private _attachedMesh;
  40040. /**
  40041. * Ratio for the scale of the gizmo (Default: 1)
  40042. */
  40043. scaleRatio: number;
  40044. /**
  40045. * If a custom mesh has been set (Default: false)
  40046. */
  40047. protected _customMeshSet: boolean;
  40048. /**
  40049. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  40050. * * When set, interactions will be enabled
  40051. */
  40052. attachedMesh: Nullable<AbstractMesh>;
  40053. /**
  40054. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  40055. * @param mesh The mesh to replace the default mesh of the gizmo
  40056. */
  40057. setCustomMesh(mesh: Mesh): void;
  40058. /**
  40059. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  40060. */
  40061. updateGizmoRotationToMatchAttachedMesh: boolean;
  40062. /**
  40063. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  40064. */
  40065. updateGizmoPositionToMatchAttachedMesh: boolean;
  40066. /**
  40067. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  40068. */
  40069. protected _updateScale: boolean;
  40070. protected _interactionsEnabled: boolean;
  40071. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40072. private _beforeRenderObserver;
  40073. private _tempVector;
  40074. /**
  40075. * Creates a gizmo
  40076. * @param gizmoLayer The utility layer the gizmo will be added to
  40077. */
  40078. constructor(
  40079. /** The utility layer the gizmo will be added to */
  40080. gizmoLayer?: UtilityLayerRenderer);
  40081. /**
  40082. * Updates the gizmo to match the attached mesh's position/rotation
  40083. */
  40084. protected _update(): void;
  40085. /**
  40086. * Disposes of the gizmo
  40087. */
  40088. dispose(): void;
  40089. }
  40090. }
  40091. declare module BABYLON {
  40092. /**
  40093. * Single axis drag gizmo
  40094. */
  40095. export class AxisDragGizmo extends Gizmo {
  40096. /**
  40097. * Drag behavior responsible for the gizmos dragging interactions
  40098. */
  40099. dragBehavior: PointerDragBehavior;
  40100. private _pointerObserver;
  40101. /**
  40102. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  40103. */
  40104. snapDistance: number;
  40105. /**
  40106. * Event that fires each time the gizmo snaps to a new location.
  40107. * * snapDistance is the the change in distance
  40108. */
  40109. onSnapObservable: Observable<{
  40110. snapDistance: number;
  40111. }>;
  40112. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  40113. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  40114. /**
  40115. * Creates an AxisDragGizmo
  40116. * @param gizmoLayer The utility layer the gizmo will be added to
  40117. * @param dragAxis The axis which the gizmo will be able to drag on
  40118. * @param color The color of the gizmo
  40119. */
  40120. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  40121. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  40122. /**
  40123. * Disposes of the gizmo
  40124. */
  40125. dispose(): void;
  40126. }
  40127. }
  40128. declare module BABYLON.Debug {
  40129. /**
  40130. * The Axes viewer will show 3 axes in a specific point in space
  40131. */
  40132. export class AxesViewer {
  40133. private _xAxis;
  40134. private _yAxis;
  40135. private _zAxis;
  40136. private _scaleLinesFactor;
  40137. private _instanced;
  40138. /**
  40139. * Gets the hosting scene
  40140. */
  40141. scene: Scene;
  40142. /**
  40143. * Gets or sets a number used to scale line length
  40144. */
  40145. scaleLines: number;
  40146. /** Gets the node hierarchy used to render x-axis */
  40147. readonly xAxis: TransformNode;
  40148. /** Gets the node hierarchy used to render y-axis */
  40149. readonly yAxis: TransformNode;
  40150. /** Gets the node hierarchy used to render z-axis */
  40151. readonly zAxis: TransformNode;
  40152. /**
  40153. * Creates a new AxesViewer
  40154. * @param scene defines the hosting scene
  40155. * @param scaleLines defines a number used to scale line length (1 by default)
  40156. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  40157. * @param xAxis defines the node hierarchy used to render the x-axis
  40158. * @param yAxis defines the node hierarchy used to render the y-axis
  40159. * @param zAxis defines the node hierarchy used to render the z-axis
  40160. */
  40161. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  40162. /**
  40163. * Force the viewer to update
  40164. * @param position defines the position of the viewer
  40165. * @param xaxis defines the x axis of the viewer
  40166. * @param yaxis defines the y axis of the viewer
  40167. * @param zaxis defines the z axis of the viewer
  40168. */
  40169. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  40170. /**
  40171. * Creates an instance of this axes viewer.
  40172. * @returns a new axes viewer with instanced meshes
  40173. */
  40174. createInstance(): AxesViewer;
  40175. /** Releases resources */
  40176. dispose(): void;
  40177. private static _SetRenderingGroupId;
  40178. }
  40179. }
  40180. declare module BABYLON.Debug {
  40181. /**
  40182. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  40183. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  40184. */
  40185. export class BoneAxesViewer extends AxesViewer {
  40186. /**
  40187. * Gets or sets the target mesh where to display the axes viewer
  40188. */
  40189. mesh: Nullable<Mesh>;
  40190. /**
  40191. * Gets or sets the target bone where to display the axes viewer
  40192. */
  40193. bone: Nullable<Bone>;
  40194. /** Gets current position */
  40195. pos: Vector3;
  40196. /** Gets direction of X axis */
  40197. xaxis: Vector3;
  40198. /** Gets direction of Y axis */
  40199. yaxis: Vector3;
  40200. /** Gets direction of Z axis */
  40201. zaxis: Vector3;
  40202. /**
  40203. * Creates a new BoneAxesViewer
  40204. * @param scene defines the hosting scene
  40205. * @param bone defines the target bone
  40206. * @param mesh defines the target mesh
  40207. * @param scaleLines defines a scaling factor for line length (1 by default)
  40208. */
  40209. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  40210. /**
  40211. * Force the viewer to update
  40212. */
  40213. update(): void;
  40214. /** Releases resources */
  40215. dispose(): void;
  40216. }
  40217. }
  40218. declare module BABYLON {
  40219. /**
  40220. * Interface used to define scene explorer extensibility option
  40221. */
  40222. export interface IExplorerExtensibilityOption {
  40223. /**
  40224. * Define the option label
  40225. */
  40226. label: string;
  40227. /**
  40228. * Defines the action to execute on click
  40229. */
  40230. action: (entity: any) => void;
  40231. }
  40232. /**
  40233. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  40234. */
  40235. export interface IExplorerExtensibilityGroup {
  40236. /**
  40237. * Defines a predicate to test if a given type mut be extended
  40238. */
  40239. predicate: (entity: any) => boolean;
  40240. /**
  40241. * Gets the list of options added to a type
  40242. */
  40243. entries: IExplorerExtensibilityOption[];
  40244. }
  40245. /**
  40246. * Interface used to define the options to use to create the Inspector
  40247. */
  40248. export interface IInspectorOptions {
  40249. /**
  40250. * Display in overlay mode (default: false)
  40251. */
  40252. overlay?: boolean;
  40253. /**
  40254. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  40255. */
  40256. globalRoot?: HTMLElement;
  40257. /**
  40258. * Display the Scene explorer
  40259. */
  40260. showExplorer?: boolean;
  40261. /**
  40262. * Display the property inspector
  40263. */
  40264. showInspector?: boolean;
  40265. /**
  40266. * Display in embed mode (both panes on the right)
  40267. */
  40268. embedMode?: boolean;
  40269. /**
  40270. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  40271. */
  40272. handleResize?: boolean;
  40273. /**
  40274. * Allow the panes to popup (default: true)
  40275. */
  40276. enablePopup?: boolean;
  40277. /**
  40278. * Allow the panes to be closed by users (default: true)
  40279. */
  40280. enableClose?: boolean;
  40281. /**
  40282. * Optional list of extensibility entries
  40283. */
  40284. explorerExtensibility?: IExplorerExtensibilityGroup[];
  40285. /**
  40286. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  40287. */
  40288. inspectorURL?: string;
  40289. }
  40290. interface Scene {
  40291. /**
  40292. * @hidden
  40293. * Backing field
  40294. */ private _debugLayer: DebugLayer;
  40295. /**
  40296. * Gets the debug layer (aka Inspector) associated with the scene
  40297. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40298. */
  40299. debugLayer: DebugLayer;
  40300. }
  40301. /**
  40302. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40303. * what is happening in your scene
  40304. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40305. */
  40306. export class DebugLayer {
  40307. /**
  40308. * Define the url to get the inspector script from.
  40309. * By default it uses the babylonjs CDN.
  40310. * @ignoreNaming
  40311. */
  40312. static InspectorURL: string;
  40313. private _scene;
  40314. private BJSINSPECTOR;
  40315. /**
  40316. * Observable triggered when a property is changed through the inspector.
  40317. */
  40318. onPropertyChangedObservable: Observable<{
  40319. object: any;
  40320. property: string;
  40321. value: any;
  40322. initialValue: any;
  40323. }>;
  40324. /**
  40325. * Instantiates a new debug layer.
  40326. * The debug layer (aka Inspector) is the go to tool in order to better understand
  40327. * what is happening in your scene
  40328. * @see http://doc.babylonjs.com/features/playground_debuglayer
  40329. * @param scene Defines the scene to inspect
  40330. */
  40331. constructor(scene: Scene);
  40332. /** Creates the inspector window. */
  40333. private _createInspector;
  40334. /**
  40335. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  40336. * @param entity defines the entity to select
  40337. * @param lineContainerTitle defines the specific block to highlight
  40338. */
  40339. select(entity: any, lineContainerTitle?: string): void;
  40340. /** Get the inspector from bundle or global */
  40341. private _getGlobalInspector;
  40342. /**
  40343. * Get if the inspector is visible or not.
  40344. * @returns true if visible otherwise, false
  40345. */
  40346. isVisible(): boolean;
  40347. /**
  40348. * Hide the inspector and close its window.
  40349. */
  40350. hide(): void;
  40351. /**
  40352. * Launch the debugLayer.
  40353. * @param config Define the configuration of the inspector
  40354. * @return a promise fulfilled when the debug layer is visible
  40355. */
  40356. show(config?: IInspectorOptions): Promise<DebugLayer>;
  40357. }
  40358. }
  40359. declare module BABYLON {
  40360. /**
  40361. * Class containing static functions to help procedurally build meshes
  40362. */
  40363. export class BoxBuilder {
  40364. /**
  40365. * Creates a box mesh
  40366. * * The parameter `size` sets the size (float) of each box side (default 1)
  40367. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  40368. * * 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)
  40369. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  40370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40373. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  40374. * @param name defines the name of the mesh
  40375. * @param options defines the options used to create the mesh
  40376. * @param scene defines the hosting scene
  40377. * @returns the box mesh
  40378. */
  40379. static CreateBox(name: string, options: {
  40380. size?: number;
  40381. width?: number;
  40382. height?: number;
  40383. depth?: number;
  40384. faceUV?: Vector4[];
  40385. faceColors?: Color4[];
  40386. sideOrientation?: number;
  40387. frontUVs?: Vector4;
  40388. backUVs?: Vector4;
  40389. wrap?: boolean;
  40390. topBaseAt?: number;
  40391. bottomBaseAt?: number;
  40392. updatable?: boolean;
  40393. }, scene?: Nullable<Scene>): Mesh;
  40394. }
  40395. }
  40396. declare module BABYLON {
  40397. /**
  40398. * Class containing static functions to help procedurally build meshes
  40399. */
  40400. export class SphereBuilder {
  40401. /**
  40402. * Creates a sphere mesh
  40403. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  40404. * * 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`)
  40405. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  40406. * * 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
  40407. * * 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)
  40408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40409. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40411. * @param name defines the name of the mesh
  40412. * @param options defines the options used to create the mesh
  40413. * @param scene defines the hosting scene
  40414. * @returns the sphere mesh
  40415. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  40416. */
  40417. static CreateSphere(name: string, options: {
  40418. segments?: number;
  40419. diameter?: number;
  40420. diameterX?: number;
  40421. diameterY?: number;
  40422. diameterZ?: number;
  40423. arc?: number;
  40424. slice?: number;
  40425. sideOrientation?: number;
  40426. frontUVs?: Vector4;
  40427. backUVs?: Vector4;
  40428. updatable?: boolean;
  40429. }, scene: any): Mesh;
  40430. }
  40431. }
  40432. declare module BABYLON.Debug {
  40433. /**
  40434. * Used to show the physics impostor around the specific mesh
  40435. */
  40436. export class PhysicsViewer {
  40437. /** @hidden */
  40438. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  40439. /** @hidden */
  40440. protected _meshes: Array<Nullable<AbstractMesh>>;
  40441. /** @hidden */
  40442. protected _scene: Nullable<Scene>;
  40443. /** @hidden */
  40444. protected _numMeshes: number;
  40445. /** @hidden */
  40446. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  40447. private _renderFunction;
  40448. private _utilityLayer;
  40449. private _debugBoxMesh;
  40450. private _debugSphereMesh;
  40451. private _debugCylinderMesh;
  40452. private _debugMaterial;
  40453. private _debugMeshMeshes;
  40454. /**
  40455. * Creates a new PhysicsViewer
  40456. * @param scene defines the hosting scene
  40457. */
  40458. constructor(scene: Scene);
  40459. /** @hidden */
  40460. protected _updateDebugMeshes(): void;
  40461. /**
  40462. * Renders a specified physic impostor
  40463. * @param impostor defines the impostor to render
  40464. * @param targetMesh defines the mesh represented by the impostor
  40465. * @returns the new debug mesh used to render the impostor
  40466. */
  40467. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  40468. /**
  40469. * Hides a specified physic impostor
  40470. * @param impostor defines the impostor to hide
  40471. */
  40472. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  40473. private _getDebugMaterial;
  40474. private _getDebugBoxMesh;
  40475. private _getDebugSphereMesh;
  40476. private _getDebugCylinderMesh;
  40477. private _getDebugMeshMesh;
  40478. private _getDebugMesh;
  40479. /** Releases all resources */
  40480. dispose(): void;
  40481. }
  40482. }
  40483. declare module BABYLON {
  40484. /**
  40485. * Class containing static functions to help procedurally build meshes
  40486. */
  40487. export class LinesBuilder {
  40488. /**
  40489. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  40490. * * 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
  40491. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  40492. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  40493. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  40494. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  40495. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  40496. * * 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
  40497. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  40498. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  40500. * @param name defines the name of the new line system
  40501. * @param options defines the options used to create the line system
  40502. * @param scene defines the hosting scene
  40503. * @returns a new line system mesh
  40504. */
  40505. static CreateLineSystem(name: string, options: {
  40506. lines: Vector3[][];
  40507. updatable?: boolean;
  40508. instance?: Nullable<LinesMesh>;
  40509. colors?: Nullable<Color4[][]>;
  40510. useVertexAlpha?: boolean;
  40511. }, scene: Nullable<Scene>): LinesMesh;
  40512. /**
  40513. * Creates a line mesh
  40514. * 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
  40515. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40516. * * The parameter `points` is an array successive Vector3
  40517. * * 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
  40518. * * The optional parameter `colors` is an array of successive Color4, one per line point
  40519. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  40520. * * When updating an instance, remember that only point positions can change, not the number of points
  40521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40522. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  40523. * @param name defines the name of the new line system
  40524. * @param options defines the options used to create the line system
  40525. * @param scene defines the hosting scene
  40526. * @returns a new line mesh
  40527. */
  40528. static CreateLines(name: string, options: {
  40529. points: Vector3[];
  40530. updatable?: boolean;
  40531. instance?: Nullable<LinesMesh>;
  40532. colors?: Color4[];
  40533. useVertexAlpha?: boolean;
  40534. }, scene?: Nullable<Scene>): LinesMesh;
  40535. /**
  40536. * Creates a dashed line mesh
  40537. * * 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
  40538. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  40539. * * The parameter `points` is an array successive Vector3
  40540. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  40541. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  40542. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  40543. * * 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
  40544. * * When updating an instance, remember that only point positions can change, not the number of points
  40545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40546. * @param name defines the name of the mesh
  40547. * @param options defines the options used to create the mesh
  40548. * @param scene defines the hosting scene
  40549. * @returns the dashed line mesh
  40550. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  40551. */
  40552. static CreateDashedLines(name: string, options: {
  40553. points: Vector3[];
  40554. dashSize?: number;
  40555. gapSize?: number;
  40556. dashNb?: number;
  40557. updatable?: boolean;
  40558. instance?: LinesMesh;
  40559. }, scene?: Nullable<Scene>): LinesMesh;
  40560. }
  40561. }
  40562. declare module BABYLON {
  40563. /**
  40564. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40565. * in order to better appreciate the issue one might have.
  40566. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40567. */
  40568. export class RayHelper {
  40569. /**
  40570. * Defines the ray we are currently tryin to visualize.
  40571. */
  40572. ray: Nullable<Ray>;
  40573. private _renderPoints;
  40574. private _renderLine;
  40575. private _renderFunction;
  40576. private _scene;
  40577. private _updateToMeshFunction;
  40578. private _attachedToMesh;
  40579. private _meshSpaceDirection;
  40580. private _meshSpaceOrigin;
  40581. /**
  40582. * Helper function to create a colored helper in a scene in one line.
  40583. * @param ray Defines the ray we are currently tryin to visualize
  40584. * @param scene Defines the scene the ray is used in
  40585. * @param color Defines the color we want to see the ray in
  40586. * @returns The newly created ray helper.
  40587. */
  40588. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  40589. /**
  40590. * Instantiate a new ray helper.
  40591. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  40592. * in order to better appreciate the issue one might have.
  40593. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  40594. * @param ray Defines the ray we are currently tryin to visualize
  40595. */
  40596. constructor(ray: Ray);
  40597. /**
  40598. * Shows the ray we are willing to debug.
  40599. * @param scene Defines the scene the ray needs to be rendered in
  40600. * @param color Defines the color the ray needs to be rendered in
  40601. */
  40602. show(scene: Scene, color?: Color3): void;
  40603. /**
  40604. * Hides the ray we are debugging.
  40605. */
  40606. hide(): void;
  40607. private _render;
  40608. /**
  40609. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  40610. * @param mesh Defines the mesh we want the helper attached to
  40611. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  40612. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  40613. * @param length Defines the length of the ray
  40614. */
  40615. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  40616. /**
  40617. * Detach the ray helper from the mesh it has previously been attached to.
  40618. */
  40619. detachFromMesh(): void;
  40620. private _updateToMesh;
  40621. /**
  40622. * Dispose the helper and release its associated resources.
  40623. */
  40624. dispose(): void;
  40625. }
  40626. }
  40627. declare module BABYLON.Debug {
  40628. /**
  40629. * Class used to render a debug view of a given skeleton
  40630. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  40631. */
  40632. export class SkeletonViewer {
  40633. /** defines the skeleton to render */
  40634. skeleton: Skeleton;
  40635. /** defines the mesh attached to the skeleton */
  40636. mesh: AbstractMesh;
  40637. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40638. autoUpdateBonesMatrices: boolean;
  40639. /** defines the rendering group id to use with the viewer */
  40640. renderingGroupId: number;
  40641. /** Gets or sets the color used to render the skeleton */
  40642. color: Color3;
  40643. private _scene;
  40644. private _debugLines;
  40645. private _debugMesh;
  40646. private _isEnabled;
  40647. private _renderFunction;
  40648. private _utilityLayer;
  40649. /**
  40650. * Returns the mesh used to render the bones
  40651. */
  40652. readonly debugMesh: Nullable<LinesMesh>;
  40653. /**
  40654. * Creates a new SkeletonViewer
  40655. * @param skeleton defines the skeleton to render
  40656. * @param mesh defines the mesh attached to the skeleton
  40657. * @param scene defines the hosting scene
  40658. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  40659. * @param renderingGroupId defines the rendering group id to use with the viewer
  40660. */
  40661. constructor(
  40662. /** defines the skeleton to render */
  40663. skeleton: Skeleton,
  40664. /** defines the mesh attached to the skeleton */
  40665. mesh: AbstractMesh, scene: Scene,
  40666. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  40667. autoUpdateBonesMatrices?: boolean,
  40668. /** defines the rendering group id to use with the viewer */
  40669. renderingGroupId?: number);
  40670. /** Gets or sets a boolean indicating if the viewer is enabled */
  40671. isEnabled: boolean;
  40672. private _getBonePosition;
  40673. private _getLinesForBonesWithLength;
  40674. private _getLinesForBonesNoLength;
  40675. /** Update the viewer to sync with current skeleton state */
  40676. update(): void;
  40677. /** Release associated resources */
  40678. dispose(): void;
  40679. }
  40680. }
  40681. declare module BABYLON {
  40682. /**
  40683. * Options to create the null engine
  40684. */
  40685. export class NullEngineOptions {
  40686. /**
  40687. * Render width (Default: 512)
  40688. */
  40689. renderWidth: number;
  40690. /**
  40691. * Render height (Default: 256)
  40692. */
  40693. renderHeight: number;
  40694. /**
  40695. * Texture size (Default: 512)
  40696. */
  40697. textureSize: number;
  40698. /**
  40699. * If delta time between frames should be constant
  40700. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40701. */
  40702. deterministicLockstep: boolean;
  40703. /**
  40704. * Maximum about of steps between frames (Default: 4)
  40705. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40706. */
  40707. lockstepMaxSteps: number;
  40708. }
  40709. /**
  40710. * The null engine class provides support for headless version of babylon.js.
  40711. * This can be used in server side scenario or for testing purposes
  40712. */
  40713. export class NullEngine extends Engine {
  40714. private _options;
  40715. /**
  40716. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40717. */
  40718. isDeterministicLockStep(): boolean;
  40719. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  40720. getLockstepMaxSteps(): number;
  40721. /**
  40722. * Sets hardware scaling, used to save performance if needed
  40723. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  40724. */
  40725. getHardwareScalingLevel(): number;
  40726. constructor(options?: NullEngineOptions);
  40727. createVertexBuffer(vertices: FloatArray): DataBuffer;
  40728. createIndexBuffer(indices: IndicesArray): DataBuffer;
  40729. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40730. getRenderWidth(useScreen?: boolean): number;
  40731. getRenderHeight(useScreen?: boolean): number;
  40732. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  40733. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  40734. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40735. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40736. bindSamplers(effect: Effect): void;
  40737. enableEffect(effect: Effect): void;
  40738. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40739. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  40740. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  40741. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  40742. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  40743. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  40744. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  40745. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  40746. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  40747. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  40748. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  40749. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  40750. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  40751. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  40752. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  40753. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40754. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  40755. setFloat(uniform: WebGLUniformLocation, value: number): void;
  40756. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  40757. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  40758. setBool(uniform: WebGLUniformLocation, bool: number): void;
  40759. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  40760. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  40761. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  40762. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  40763. bindBuffers(vertexBuffers: {
  40764. [key: string]: VertexBuffer;
  40765. }, indexBuffer: DataBuffer, effect: Effect): void;
  40766. wipeCaches(bruteForce?: boolean): void;
  40767. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40768. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40769. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40770. /** @hidden */ private _createTexture(): WebGLTexture;
  40771. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  40772. 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;
  40773. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  40774. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  40775. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  40776. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40777. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  40778. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  40779. areAllEffectsReady(): boolean;
  40780. /**
  40781. * @hidden
  40782. * Get the current error code of the webGL context
  40783. * @returns the error code
  40784. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  40785. */
  40786. getError(): number;
  40787. /** @hidden */ private _getUnpackAlignement(): number;
  40788. /** @hidden */ private _unpackFlipY(value: boolean): void;
  40789. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  40790. /**
  40791. * Updates a dynamic vertex buffer.
  40792. * @param vertexBuffer the vertex buffer to update
  40793. * @param data the data used to update the vertex buffer
  40794. * @param byteOffset the byte offset of the data (optional)
  40795. * @param byteLength the byte length of the data (optional)
  40796. */
  40797. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  40798. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  40799. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  40800. releaseEffects(): void;
  40801. displayLoadingUI(): void;
  40802. hideLoadingUI(): void;
  40803. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40804. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40805. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  40806. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  40807. }
  40808. }
  40809. declare module BABYLON {
  40810. /** @hidden */
  40811. export class _OcclusionDataStorage {
  40812. /** @hidden */
  40813. occlusionInternalRetryCounter: number;
  40814. /** @hidden */
  40815. isOcclusionQueryInProgress: boolean;
  40816. /** @hidden */
  40817. isOccluded: boolean;
  40818. /** @hidden */
  40819. occlusionRetryCount: number;
  40820. /** @hidden */
  40821. occlusionType: number;
  40822. /** @hidden */
  40823. occlusionQueryAlgorithmType: number;
  40824. }
  40825. interface Engine {
  40826. /**
  40827. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  40828. * @return the new query
  40829. */
  40830. createQuery(): WebGLQuery;
  40831. /**
  40832. * Delete and release a webGL query
  40833. * @param query defines the query to delete
  40834. * @return the current engine
  40835. */
  40836. deleteQuery(query: WebGLQuery): Engine;
  40837. /**
  40838. * Check if a given query has resolved and got its value
  40839. * @param query defines the query to check
  40840. * @returns true if the query got its value
  40841. */
  40842. isQueryResultAvailable(query: WebGLQuery): boolean;
  40843. /**
  40844. * Gets the value of a given query
  40845. * @param query defines the query to check
  40846. * @returns the value of the query
  40847. */
  40848. getQueryResult(query: WebGLQuery): number;
  40849. /**
  40850. * Initiates an occlusion query
  40851. * @param algorithmType defines the algorithm to use
  40852. * @param query defines the query to use
  40853. * @returns the current engine
  40854. * @see http://doc.babylonjs.com/features/occlusionquery
  40855. */
  40856. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  40857. /**
  40858. * Ends an occlusion query
  40859. * @see http://doc.babylonjs.com/features/occlusionquery
  40860. * @param algorithmType defines the algorithm to use
  40861. * @returns the current engine
  40862. */
  40863. endOcclusionQuery(algorithmType: number): Engine;
  40864. /**
  40865. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  40866. * Please note that only one query can be issued at a time
  40867. * @returns a time token used to track the time span
  40868. */
  40869. startTimeQuery(): Nullable<_TimeToken>;
  40870. /**
  40871. * Ends a time query
  40872. * @param token defines the token used to measure the time span
  40873. * @returns the time spent (in ns)
  40874. */
  40875. endTimeQuery(token: _TimeToken): int;
  40876. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  40877. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  40878. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  40879. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  40880. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  40881. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  40882. }
  40883. interface AbstractMesh {
  40884. /**
  40885. * Backing filed
  40886. * @hidden
  40887. */ private __occlusionDataStorage: _OcclusionDataStorage;
  40888. /**
  40889. * Access property
  40890. * @hidden
  40891. */ private _occlusionDataStorage: _OcclusionDataStorage;
  40892. /**
  40893. * 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.
  40894. * The default value is -1 which means don't break the query and wait till the result
  40895. * @see http://doc.babylonjs.com/features/occlusionquery
  40896. */
  40897. occlusionRetryCount: number;
  40898. /**
  40899. * 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:
  40900. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  40901. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  40902. * * 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.
  40903. * @see http://doc.babylonjs.com/features/occlusionquery
  40904. */
  40905. occlusionType: number;
  40906. /**
  40907. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  40908. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  40909. * * 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.
  40910. * @see http://doc.babylonjs.com/features/occlusionquery
  40911. */
  40912. occlusionQueryAlgorithmType: number;
  40913. /**
  40914. * 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
  40915. * @see http://doc.babylonjs.com/features/occlusionquery
  40916. */
  40917. isOccluded: boolean;
  40918. /**
  40919. * Flag to check the progress status of the query
  40920. * @see http://doc.babylonjs.com/features/occlusionquery
  40921. */
  40922. isOcclusionQueryInProgress: boolean;
  40923. }
  40924. }
  40925. declare module BABYLON {
  40926. /** @hidden */
  40927. export var _forceTransformFeedbackToBundle: boolean;
  40928. interface Engine {
  40929. /**
  40930. * Creates a webGL transform feedback object
  40931. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  40932. * @returns the webGL transform feedback object
  40933. */
  40934. createTransformFeedback(): WebGLTransformFeedback;
  40935. /**
  40936. * Delete a webGL transform feedback object
  40937. * @param value defines the webGL transform feedback object to delete
  40938. */
  40939. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  40940. /**
  40941. * Bind a webGL transform feedback object to the webgl context
  40942. * @param value defines the webGL transform feedback object to bind
  40943. */
  40944. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  40945. /**
  40946. * Begins a transform feedback operation
  40947. * @param usePoints defines if points or triangles must be used
  40948. */
  40949. beginTransformFeedback(usePoints: boolean): void;
  40950. /**
  40951. * Ends a transform feedback operation
  40952. */
  40953. endTransformFeedback(): void;
  40954. /**
  40955. * Specify the varyings to use with transform feedback
  40956. * @param program defines the associated webGL program
  40957. * @param value defines the list of strings representing the varying names
  40958. */
  40959. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  40960. /**
  40961. * Bind a webGL buffer for a transform feedback operation
  40962. * @param value defines the webGL buffer to bind
  40963. */
  40964. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  40965. }
  40966. }
  40967. declare module BABYLON {
  40968. /**
  40969. * Creation options of the multi render target texture.
  40970. */
  40971. export interface IMultiRenderTargetOptions {
  40972. /**
  40973. * Define if the texture needs to create mip maps after render.
  40974. */
  40975. generateMipMaps?: boolean;
  40976. /**
  40977. * Define the types of all the draw buffers we want to create
  40978. */
  40979. types?: number[];
  40980. /**
  40981. * Define the sampling modes of all the draw buffers we want to create
  40982. */
  40983. samplingModes?: number[];
  40984. /**
  40985. * Define if a depth buffer is required
  40986. */
  40987. generateDepthBuffer?: boolean;
  40988. /**
  40989. * Define if a stencil buffer is required
  40990. */
  40991. generateStencilBuffer?: boolean;
  40992. /**
  40993. * Define if a depth texture is required instead of a depth buffer
  40994. */
  40995. generateDepthTexture?: boolean;
  40996. /**
  40997. * Define the number of desired draw buffers
  40998. */
  40999. textureCount?: number;
  41000. /**
  41001. * Define if aspect ratio should be adapted to the texture or stay the scene one
  41002. */
  41003. doNotChangeAspectRatio?: boolean;
  41004. /**
  41005. * Define the default type of the buffers we are creating
  41006. */
  41007. defaultType?: number;
  41008. }
  41009. /**
  41010. * A multi render target, like a render target provides the ability to render to a texture.
  41011. * Unlike the render target, it can render to several draw buffers in one draw.
  41012. * This is specially interesting in deferred rendering or for any effects requiring more than
  41013. * just one color from a single pass.
  41014. */
  41015. export class MultiRenderTarget extends RenderTargetTexture {
  41016. private _internalTextures;
  41017. private _textures;
  41018. private _multiRenderTargetOptions;
  41019. /**
  41020. * Get if draw buffers are currently supported by the used hardware and browser.
  41021. */
  41022. readonly isSupported: boolean;
  41023. /**
  41024. * Get the list of textures generated by the multi render target.
  41025. */
  41026. readonly textures: Texture[];
  41027. /**
  41028. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  41029. */
  41030. readonly depthTexture: Texture;
  41031. /**
  41032. * Set the wrapping mode on U of all the textures we are rendering to.
  41033. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41034. */
  41035. wrapU: number;
  41036. /**
  41037. * Set the wrapping mode on V of all the textures we are rendering to.
  41038. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  41039. */
  41040. wrapV: number;
  41041. /**
  41042. * Instantiate a new multi render target texture.
  41043. * A multi render target, like a render target provides the ability to render to a texture.
  41044. * Unlike the render target, it can render to several draw buffers in one draw.
  41045. * This is specially interesting in deferred rendering or for any effects requiring more than
  41046. * just one color from a single pass.
  41047. * @param name Define the name of the texture
  41048. * @param size Define the size of the buffers to render to
  41049. * @param count Define the number of target we are rendering into
  41050. * @param scene Define the scene the texture belongs to
  41051. * @param options Define the options used to create the multi render target
  41052. */
  41053. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  41054. /** @hidden */ private _rebuild(): void;
  41055. private _createInternalTextures;
  41056. private _createTextures;
  41057. /**
  41058. * Define the number of samples used if MSAA is enabled.
  41059. */
  41060. samples: number;
  41061. /**
  41062. * Resize all the textures in the multi render target.
  41063. * Be carrefull as it will recreate all the data in the new texture.
  41064. * @param size Define the new size
  41065. */
  41066. resize(size: any): void;
  41067. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  41068. /**
  41069. * Dispose the render targets and their associated resources
  41070. */
  41071. dispose(): void;
  41072. /**
  41073. * Release all the underlying texture used as draw buffers.
  41074. */
  41075. releaseInternalTextures(): void;
  41076. }
  41077. }
  41078. declare module BABYLON {
  41079. interface Engine {
  41080. /**
  41081. * Unbind a list of render target textures from the webGL context
  41082. * This is used only when drawBuffer extension or webGL2 are active
  41083. * @param textures defines the render target textures to unbind
  41084. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  41085. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  41086. */
  41087. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  41088. /**
  41089. * Create a multi render target texture
  41090. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  41091. * @param size defines the size of the texture
  41092. * @param options defines the creation options
  41093. * @returns the cube texture as an InternalTexture
  41094. */
  41095. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  41096. /**
  41097. * Update the sample count for a given multiple render target texture
  41098. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41099. * @param textures defines the textures to update
  41100. * @param samples defines the sample count to set
  41101. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41102. */
  41103. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  41104. }
  41105. }
  41106. declare module BABYLON {
  41107. /**
  41108. * Gather the list of clipboard event types as constants.
  41109. */
  41110. export class ClipboardEventTypes {
  41111. /**
  41112. * The clipboard event is fired when a copy command is active (pressed).
  41113. */
  41114. static readonly COPY: number;
  41115. /**
  41116. * The clipboard event is fired when a cut command is active (pressed).
  41117. */
  41118. static readonly CUT: number;
  41119. /**
  41120. * The clipboard event is fired when a paste command is active (pressed).
  41121. */
  41122. static readonly PASTE: number;
  41123. }
  41124. /**
  41125. * This class is used to store clipboard related info for the onClipboardObservable event.
  41126. */
  41127. export class ClipboardInfo {
  41128. /**
  41129. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41130. */
  41131. type: number;
  41132. /**
  41133. * Defines the related dom event
  41134. */
  41135. event: ClipboardEvent;
  41136. /**
  41137. *Creates an instance of ClipboardInfo.
  41138. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  41139. * @param event Defines the related dom event
  41140. */
  41141. constructor(
  41142. /**
  41143. * Defines the type of event (BABYLON.ClipboardEventTypes)
  41144. */
  41145. type: number,
  41146. /**
  41147. * Defines the related dom event
  41148. */
  41149. event: ClipboardEvent);
  41150. /**
  41151. * Get the clipboard event's type from the keycode.
  41152. * @param keyCode Defines the keyCode for the current keyboard event.
  41153. * @return {number}
  41154. */
  41155. static GetTypeFromCharacter(keyCode: number): number;
  41156. }
  41157. }
  41158. declare module BABYLON {
  41159. /**
  41160. * Class used to represent data loading progression
  41161. */
  41162. export class SceneLoaderProgressEvent {
  41163. /** defines if data length to load can be evaluated */
  41164. readonly lengthComputable: boolean;
  41165. /** defines the loaded data length */
  41166. readonly loaded: number;
  41167. /** defines the data length to load */
  41168. readonly total: number;
  41169. /**
  41170. * Create a new progress event
  41171. * @param lengthComputable defines if data length to load can be evaluated
  41172. * @param loaded defines the loaded data length
  41173. * @param total defines the data length to load
  41174. */
  41175. constructor(
  41176. /** defines if data length to load can be evaluated */
  41177. lengthComputable: boolean,
  41178. /** defines the loaded data length */
  41179. loaded: number,
  41180. /** defines the data length to load */
  41181. total: number);
  41182. /**
  41183. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  41184. * @param event defines the source event
  41185. * @returns a new SceneLoaderProgressEvent
  41186. */
  41187. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  41188. }
  41189. /**
  41190. * Interface used by SceneLoader plugins to define supported file extensions
  41191. */
  41192. export interface ISceneLoaderPluginExtensions {
  41193. /**
  41194. * Defines the list of supported extensions
  41195. */
  41196. [extension: string]: {
  41197. isBinary: boolean;
  41198. };
  41199. }
  41200. /**
  41201. * Interface used by SceneLoader plugin factory
  41202. */
  41203. export interface ISceneLoaderPluginFactory {
  41204. /**
  41205. * Defines the name of the factory
  41206. */
  41207. name: string;
  41208. /**
  41209. * Function called to create a new plugin
  41210. * @return the new plugin
  41211. */
  41212. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  41213. /**
  41214. * Boolean indicating if the plugin can direct load specific data
  41215. */
  41216. canDirectLoad?: (data: string) => boolean;
  41217. }
  41218. /**
  41219. * Interface used to define a SceneLoader plugin
  41220. */
  41221. export interface ISceneLoaderPlugin {
  41222. /**
  41223. * The friendly name of this plugin.
  41224. */
  41225. name: string;
  41226. /**
  41227. * The file extensions supported by this plugin.
  41228. */
  41229. extensions: string | ISceneLoaderPluginExtensions;
  41230. /**
  41231. * Import meshes into a scene.
  41232. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41233. * @param scene The scene to import into
  41234. * @param data The data to import
  41235. * @param rootUrl The root url for scene and resources
  41236. * @param meshes The meshes array to import into
  41237. * @param particleSystems The particle systems array to import into
  41238. * @param skeletons The skeletons array to import into
  41239. * @param onError The callback when import fails
  41240. * @returns True if successful or false otherwise
  41241. */
  41242. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  41243. /**
  41244. * Load into a scene.
  41245. * @param scene The scene to load into
  41246. * @param data The data to import
  41247. * @param rootUrl The root url for scene and resources
  41248. * @param onError The callback when import fails
  41249. * @returns true if successful or false otherwise
  41250. */
  41251. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  41252. /**
  41253. * The callback that returns true if the data can be directly loaded.
  41254. */
  41255. canDirectLoad?: (data: string) => boolean;
  41256. /**
  41257. * The callback that allows custom handling of the root url based on the response url.
  41258. */
  41259. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41260. /**
  41261. * Load into an asset container.
  41262. * @param scene The scene to load into
  41263. * @param data The data to import
  41264. * @param rootUrl The root url for scene and resources
  41265. * @param onError The callback when import fails
  41266. * @returns The loaded asset container
  41267. */
  41268. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  41269. }
  41270. /**
  41271. * Interface used to define an async SceneLoader plugin
  41272. */
  41273. export interface ISceneLoaderPluginAsync {
  41274. /**
  41275. * The friendly name of this plugin.
  41276. */
  41277. name: string;
  41278. /**
  41279. * The file extensions supported by this plugin.
  41280. */
  41281. extensions: string | ISceneLoaderPluginExtensions;
  41282. /**
  41283. * Import meshes into a scene.
  41284. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41285. * @param scene The scene to import into
  41286. * @param data The data to import
  41287. * @param rootUrl The root url for scene and resources
  41288. * @param onProgress The callback when the load progresses
  41289. * @param fileName Defines the name of the file to load
  41290. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  41291. */
  41292. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  41293. meshes: AbstractMesh[];
  41294. particleSystems: IParticleSystem[];
  41295. skeletons: Skeleton[];
  41296. animationGroups: AnimationGroup[];
  41297. }>;
  41298. /**
  41299. * Load into a scene.
  41300. * @param scene The scene to load into
  41301. * @param data The data to import
  41302. * @param rootUrl The root url for scene and resources
  41303. * @param onProgress The callback when the load progresses
  41304. * @param fileName Defines the name of the file to load
  41305. * @returns Nothing
  41306. */
  41307. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  41308. /**
  41309. * The callback that returns true if the data can be directly loaded.
  41310. */
  41311. canDirectLoad?: (data: string) => boolean;
  41312. /**
  41313. * The callback that allows custom handling of the root url based on the response url.
  41314. */
  41315. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  41316. /**
  41317. * Load into an asset container.
  41318. * @param scene The scene to load into
  41319. * @param data The data to import
  41320. * @param rootUrl The root url for scene and resources
  41321. * @param onProgress The callback when the load progresses
  41322. * @param fileName Defines the name of the file to load
  41323. * @returns The loaded asset container
  41324. */
  41325. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  41326. }
  41327. /**
  41328. * Class used to load scene from various file formats using registered plugins
  41329. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  41330. */
  41331. export class SceneLoader {
  41332. /**
  41333. * No logging while loading
  41334. */
  41335. static readonly NO_LOGGING: number;
  41336. /**
  41337. * Minimal logging while loading
  41338. */
  41339. static readonly MINIMAL_LOGGING: number;
  41340. /**
  41341. * Summary logging while loading
  41342. */
  41343. static readonly SUMMARY_LOGGING: number;
  41344. /**
  41345. * Detailled logging while loading
  41346. */
  41347. static readonly DETAILED_LOGGING: number;
  41348. /**
  41349. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41350. */
  41351. static ForceFullSceneLoadingForIncremental: boolean;
  41352. /**
  41353. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41354. */
  41355. static ShowLoadingScreen: boolean;
  41356. /**
  41357. * Defines the current logging level (while loading the scene)
  41358. * @ignorenaming
  41359. */
  41360. static loggingLevel: number;
  41361. /**
  41362. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41363. */
  41364. static CleanBoneMatrixWeights: boolean;
  41365. /**
  41366. * Event raised when a plugin is used to load a scene
  41367. */
  41368. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41369. private static _registeredPlugins;
  41370. private static _getDefaultPlugin;
  41371. private static _getPluginForExtension;
  41372. private static _getPluginForDirectLoad;
  41373. private static _getPluginForFilename;
  41374. private static _getDirectLoad;
  41375. private static _loadData;
  41376. private static _getFileInfo;
  41377. /**
  41378. * Gets a plugin that can load the given extension
  41379. * @param extension defines the extension to load
  41380. * @returns a plugin or null if none works
  41381. */
  41382. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41383. /**
  41384. * Gets a boolean indicating that the given extension can be loaded
  41385. * @param extension defines the extension to load
  41386. * @returns true if the extension is supported
  41387. */
  41388. static IsPluginForExtensionAvailable(extension: string): boolean;
  41389. /**
  41390. * Adds a new plugin to the list of registered plugins
  41391. * @param plugin defines the plugin to add
  41392. */
  41393. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41394. /**
  41395. * Import meshes into a scene
  41396. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41397. * @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)
  41398. * @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)
  41399. * @param scene the instance of BABYLON.Scene to append to
  41400. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41401. * @param onProgress a callback with a progress event for each file being loaded
  41402. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41403. * @param pluginExtension the extension used to determine the plugin
  41404. * @returns The loaded plugin
  41405. */
  41406. 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>;
  41407. /**
  41408. * Import meshes into a scene
  41409. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41410. * @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)
  41411. * @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)
  41412. * @param scene the instance of BABYLON.Scene to append to
  41413. * @param onProgress a callback with a progress event for each file being loaded
  41414. * @param pluginExtension the extension used to determine the plugin
  41415. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41416. */
  41417. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41418. meshes: AbstractMesh[];
  41419. particleSystems: IParticleSystem[];
  41420. skeletons: Skeleton[];
  41421. animationGroups: AnimationGroup[];
  41422. }>;
  41423. /**
  41424. * Load a scene
  41425. * @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)
  41426. * @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)
  41427. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41428. * @param onSuccess a callback with the scene when import succeeds
  41429. * @param onProgress a callback with a progress event for each file being loaded
  41430. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41431. * @param pluginExtension the extension used to determine the plugin
  41432. * @returns The loaded plugin
  41433. */
  41434. 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>;
  41435. /**
  41436. * Load a scene
  41437. * @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)
  41438. * @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)
  41439. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41440. * @param onProgress a callback with a progress event for each file being loaded
  41441. * @param pluginExtension the extension used to determine the plugin
  41442. * @returns The loaded scene
  41443. */
  41444. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41445. /**
  41446. * Append a scene
  41447. * @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)
  41448. * @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)
  41449. * @param scene is the instance of BABYLON.Scene to append to
  41450. * @param onSuccess a callback with the scene when import succeeds
  41451. * @param onProgress a callback with a progress event for each file being loaded
  41452. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41453. * @param pluginExtension the extension used to determine the plugin
  41454. * @returns The loaded plugin
  41455. */
  41456. 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>;
  41457. /**
  41458. * Append a scene
  41459. * @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)
  41460. * @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)
  41461. * @param scene is the instance of BABYLON.Scene to append to
  41462. * @param onProgress a callback with a progress event for each file being loaded
  41463. * @param pluginExtension the extension used to determine the plugin
  41464. * @returns The given scene
  41465. */
  41466. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41467. /**
  41468. * Load a scene into an asset container
  41469. * @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)
  41470. * @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)
  41471. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41472. * @param onSuccess a callback with the scene when import succeeds
  41473. * @param onProgress a callback with a progress event for each file being loaded
  41474. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41475. * @param pluginExtension the extension used to determine the plugin
  41476. * @returns The loaded plugin
  41477. */
  41478. 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>;
  41479. /**
  41480. * Load a scene into an asset container
  41481. * @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)
  41482. * @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)
  41483. * @param scene is the instance of Scene to append to
  41484. * @param onProgress a callback with a progress event for each file being loaded
  41485. * @param pluginExtension the extension used to determine the plugin
  41486. * @returns The loaded asset container
  41487. */
  41488. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41489. }
  41490. }
  41491. declare module BABYLON {
  41492. /**
  41493. * Google Daydream controller
  41494. */
  41495. export class DaydreamController extends WebVRController {
  41496. /**
  41497. * Base Url for the controller model.
  41498. */
  41499. static MODEL_BASE_URL: string;
  41500. /**
  41501. * File name for the controller model.
  41502. */
  41503. static MODEL_FILENAME: string;
  41504. /**
  41505. * Gamepad Id prefix used to identify Daydream Controller.
  41506. */
  41507. static readonly GAMEPAD_ID_PREFIX: string;
  41508. /**
  41509. * Creates a new DaydreamController from a gamepad
  41510. * @param vrGamepad the gamepad that the controller should be created from
  41511. */
  41512. constructor(vrGamepad: any);
  41513. /**
  41514. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41515. * @param scene scene in which to add meshes
  41516. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41517. */
  41518. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41519. /**
  41520. * Called once for each button that changed state since the last frame
  41521. * @param buttonIdx Which button index changed
  41522. * @param state New state of the button
  41523. * @param changes Which properties on the state changed since last frame
  41524. */
  41525. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41526. }
  41527. }
  41528. declare module BABYLON {
  41529. /**
  41530. * Gear VR Controller
  41531. */
  41532. export class GearVRController extends WebVRController {
  41533. /**
  41534. * Base Url for the controller model.
  41535. */
  41536. static MODEL_BASE_URL: string;
  41537. /**
  41538. * File name for the controller model.
  41539. */
  41540. static MODEL_FILENAME: string;
  41541. /**
  41542. * Gamepad Id prefix used to identify this controller.
  41543. */
  41544. static readonly GAMEPAD_ID_PREFIX: string;
  41545. private readonly _buttonIndexToObservableNameMap;
  41546. /**
  41547. * Creates a new GearVRController from a gamepad
  41548. * @param vrGamepad the gamepad that the controller should be created from
  41549. */
  41550. constructor(vrGamepad: any);
  41551. /**
  41552. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41553. * @param scene scene in which to add meshes
  41554. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41555. */
  41556. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41557. /**
  41558. * Called once for each button that changed state since the last frame
  41559. * @param buttonIdx Which button index changed
  41560. * @param state New state of the button
  41561. * @param changes Which properties on the state changed since last frame
  41562. */
  41563. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41564. }
  41565. }
  41566. declare module BABYLON {
  41567. /**
  41568. * Generic Controller
  41569. */
  41570. export class GenericController extends WebVRController {
  41571. /**
  41572. * Base Url for the controller model.
  41573. */
  41574. static readonly MODEL_BASE_URL: string;
  41575. /**
  41576. * File name for the controller model.
  41577. */
  41578. static readonly MODEL_FILENAME: string;
  41579. /**
  41580. * Creates a new GenericController from a gamepad
  41581. * @param vrGamepad the gamepad that the controller should be created from
  41582. */
  41583. constructor(vrGamepad: any);
  41584. /**
  41585. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41586. * @param scene scene in which to add meshes
  41587. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41588. */
  41589. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41590. /**
  41591. * Called once for each button that changed state since the last frame
  41592. * @param buttonIdx Which button index changed
  41593. * @param state New state of the button
  41594. * @param changes Which properties on the state changed since last frame
  41595. */
  41596. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41597. }
  41598. }
  41599. declare module BABYLON {
  41600. /**
  41601. * Oculus Touch Controller
  41602. */
  41603. export class OculusTouchController extends WebVRController {
  41604. /**
  41605. * Base Url for the controller model.
  41606. */
  41607. static MODEL_BASE_URL: string;
  41608. /**
  41609. * File name for the left controller model.
  41610. */
  41611. static MODEL_LEFT_FILENAME: string;
  41612. /**
  41613. * File name for the right controller model.
  41614. */
  41615. static MODEL_RIGHT_FILENAME: string;
  41616. /**
  41617. * Fired when the secondary trigger on this controller is modified
  41618. */
  41619. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41620. /**
  41621. * Fired when the thumb rest on this controller is modified
  41622. */
  41623. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41624. /**
  41625. * Creates a new OculusTouchController from a gamepad
  41626. * @param vrGamepad the gamepad that the controller should be created from
  41627. */
  41628. constructor(vrGamepad: any);
  41629. /**
  41630. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41631. * @param scene scene in which to add meshes
  41632. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41633. */
  41634. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41635. /**
  41636. * Fired when the A button on this controller is modified
  41637. */
  41638. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41639. /**
  41640. * Fired when the B button on this controller is modified
  41641. */
  41642. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41643. /**
  41644. * Fired when the X button on this controller is modified
  41645. */
  41646. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41647. /**
  41648. * Fired when the Y button on this controller is modified
  41649. */
  41650. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41651. /**
  41652. * Called once for each button that changed state since the last frame
  41653. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41654. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41655. * 2) secondary trigger (same)
  41656. * 3) A (right) X (left), touch, pressed = value
  41657. * 4) B / Y
  41658. * 5) thumb rest
  41659. * @param buttonIdx Which button index changed
  41660. * @param state New state of the button
  41661. * @param changes Which properties on the state changed since last frame
  41662. */
  41663. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41664. }
  41665. }
  41666. declare module BABYLON {
  41667. /**
  41668. * Vive Controller
  41669. */
  41670. export class ViveController extends WebVRController {
  41671. /**
  41672. * Base Url for the controller model.
  41673. */
  41674. static MODEL_BASE_URL: string;
  41675. /**
  41676. * File name for the controller model.
  41677. */
  41678. static MODEL_FILENAME: string;
  41679. /**
  41680. * Creates a new ViveController from a gamepad
  41681. * @param vrGamepad the gamepad that the controller should be created from
  41682. */
  41683. constructor(vrGamepad: any);
  41684. /**
  41685. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41686. * @param scene scene in which to add meshes
  41687. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41688. */
  41689. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41690. /**
  41691. * Fired when the left button on this controller is modified
  41692. */
  41693. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41694. /**
  41695. * Fired when the right button on this controller is modified
  41696. */
  41697. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41698. /**
  41699. * Fired when the menu button on this controller is modified
  41700. */
  41701. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41702. /**
  41703. * Called once for each button that changed state since the last frame
  41704. * Vive mapping:
  41705. * 0: touchpad
  41706. * 1: trigger
  41707. * 2: left AND right buttons
  41708. * 3: menu button
  41709. * @param buttonIdx Which button index changed
  41710. * @param state New state of the button
  41711. * @param changes Which properties on the state changed since last frame
  41712. */
  41713. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41714. }
  41715. }
  41716. declare module BABYLON {
  41717. /**
  41718. * Defines the WindowsMotionController object that the state of the windows motion controller
  41719. */
  41720. export class WindowsMotionController extends WebVRController {
  41721. /**
  41722. * The base url used to load the left and right controller models
  41723. */
  41724. static MODEL_BASE_URL: string;
  41725. /**
  41726. * The name of the left controller model file
  41727. */
  41728. static MODEL_LEFT_FILENAME: string;
  41729. /**
  41730. * The name of the right controller model file
  41731. */
  41732. static MODEL_RIGHT_FILENAME: string;
  41733. /**
  41734. * The controller name prefix for this controller type
  41735. */
  41736. static readonly GAMEPAD_ID_PREFIX: string;
  41737. /**
  41738. * The controller id pattern for this controller type
  41739. */
  41740. private static readonly GAMEPAD_ID_PATTERN;
  41741. private _loadedMeshInfo;
  41742. private readonly _mapping;
  41743. /**
  41744. * Fired when the trackpad on this controller is clicked
  41745. */
  41746. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41747. /**
  41748. * Fired when the trackpad on this controller is modified
  41749. */
  41750. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41751. /**
  41752. * The current x and y values of this controller's trackpad
  41753. */
  41754. trackpad: StickValues;
  41755. /**
  41756. * Creates a new WindowsMotionController from a gamepad
  41757. * @param vrGamepad the gamepad that the controller should be created from
  41758. */
  41759. constructor(vrGamepad: any);
  41760. /**
  41761. * Fired when the trigger on this controller is modified
  41762. */
  41763. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41764. /**
  41765. * Fired when the menu button on this controller is modified
  41766. */
  41767. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41768. /**
  41769. * Fired when the grip button on this controller is modified
  41770. */
  41771. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41772. /**
  41773. * Fired when the thumbstick button on this controller is modified
  41774. */
  41775. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41776. /**
  41777. * Fired when the touchpad button on this controller is modified
  41778. */
  41779. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41780. /**
  41781. * Fired when the touchpad values on this controller are modified
  41782. */
  41783. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41784. private _updateTrackpad;
  41785. /**
  41786. * Called once per frame by the engine.
  41787. */
  41788. update(): void;
  41789. /**
  41790. * Called once for each button that changed state since the last frame
  41791. * @param buttonIdx Which button index changed
  41792. * @param state New state of the button
  41793. * @param changes Which properties on the state changed since last frame
  41794. */
  41795. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41796. /**
  41797. * Moves the buttons on the controller mesh based on their current state
  41798. * @param buttonName the name of the button to move
  41799. * @param buttonValue the value of the button which determines the buttons new position
  41800. */
  41801. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41802. /**
  41803. * Moves the axis on the controller mesh based on its current state
  41804. * @param axis the index of the axis
  41805. * @param axisValue the value of the axis which determines the meshes new position
  41806. * @hidden
  41807. */
  41808. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41809. /**
  41810. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41811. * @param scene scene in which to add meshes
  41812. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41813. */
  41814. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41815. /**
  41816. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41817. * can be transformed by button presses and axes values, based on this._mapping.
  41818. *
  41819. * @param scene scene in which the meshes exist
  41820. * @param meshes list of meshes that make up the controller model to process
  41821. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41822. */
  41823. private processModel;
  41824. private createMeshInfo;
  41825. /**
  41826. * Gets the ray of the controller in the direction the controller is pointing
  41827. * @param length the length the resulting ray should be
  41828. * @returns a ray in the direction the controller is pointing
  41829. */
  41830. getForwardRay(length?: number): Ray;
  41831. /**
  41832. * Disposes of the controller
  41833. */
  41834. dispose(): void;
  41835. }
  41836. }
  41837. declare module BABYLON {
  41838. /**
  41839. * Single axis scale gizmo
  41840. */
  41841. export class AxisScaleGizmo extends Gizmo {
  41842. private _coloredMaterial;
  41843. /**
  41844. * Drag behavior responsible for the gizmos dragging interactions
  41845. */
  41846. dragBehavior: PointerDragBehavior;
  41847. private _pointerObserver;
  41848. /**
  41849. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41850. */
  41851. snapDistance: number;
  41852. /**
  41853. * Event that fires each time the gizmo snaps to a new location.
  41854. * * snapDistance is the the change in distance
  41855. */
  41856. onSnapObservable: Observable<{
  41857. snapDistance: number;
  41858. }>;
  41859. /**
  41860. * If the scaling operation should be done on all axis (default: false)
  41861. */
  41862. uniformScaling: boolean;
  41863. /**
  41864. * Creates an AxisScaleGizmo
  41865. * @param gizmoLayer The utility layer the gizmo will be added to
  41866. * @param dragAxis The axis which the gizmo will be able to scale on
  41867. * @param color The color of the gizmo
  41868. */
  41869. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41870. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41871. /**
  41872. * Disposes of the gizmo
  41873. */
  41874. dispose(): void;
  41875. /**
  41876. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41877. * @param mesh The mesh to replace the default mesh of the gizmo
  41878. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  41879. */
  41880. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  41881. }
  41882. }
  41883. declare module BABYLON {
  41884. /**
  41885. * Bounding box gizmo
  41886. */
  41887. export class BoundingBoxGizmo extends Gizmo {
  41888. private _lineBoundingBox;
  41889. private _rotateSpheresParent;
  41890. private _scaleBoxesParent;
  41891. private _boundingDimensions;
  41892. private _renderObserver;
  41893. private _pointerObserver;
  41894. private _scaleDragSpeed;
  41895. private _tmpQuaternion;
  41896. private _tmpVector;
  41897. private _tmpRotationMatrix;
  41898. /**
  41899. * 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)
  41900. */
  41901. ignoreChildren: boolean;
  41902. /**
  41903. * 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)
  41904. */
  41905. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  41906. /**
  41907. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  41908. */
  41909. rotationSphereSize: number;
  41910. /**
  41911. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  41912. */
  41913. scaleBoxSize: number;
  41914. /**
  41915. * 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)
  41916. */
  41917. fixedDragMeshScreenSize: boolean;
  41918. /**
  41919. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  41920. */
  41921. fixedDragMeshScreenSizeDistanceFactor: number;
  41922. /**
  41923. * Fired when a rotation sphere or scale box is dragged
  41924. */
  41925. onDragStartObservable: Observable<{}>;
  41926. /**
  41927. * Fired when a scale box is dragged
  41928. */
  41929. onScaleBoxDragObservable: Observable<{}>;
  41930. /**
  41931. * Fired when a scale box drag is ended
  41932. */
  41933. onScaleBoxDragEndObservable: Observable<{}>;
  41934. /**
  41935. * Fired when a rotation sphere is dragged
  41936. */
  41937. onRotationSphereDragObservable: Observable<{}>;
  41938. /**
  41939. * Fired when a rotation sphere drag is ended
  41940. */
  41941. onRotationSphereDragEndObservable: Observable<{}>;
  41942. /**
  41943. * 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)
  41944. */
  41945. scalePivot: Nullable<Vector3>;
  41946. /**
  41947. * Mesh used as a pivot to rotate the attached mesh
  41948. */
  41949. private _anchorMesh;
  41950. private _existingMeshScale;
  41951. private _dragMesh;
  41952. private pointerDragBehavior;
  41953. private coloredMaterial;
  41954. private hoverColoredMaterial;
  41955. /**
  41956. * Sets the color of the bounding box gizmo
  41957. * @param color the color to set
  41958. */
  41959. setColor(color: Color3): void;
  41960. /**
  41961. * Creates an BoundingBoxGizmo
  41962. * @param gizmoLayer The utility layer the gizmo will be added to
  41963. * @param color The color of the gizmo
  41964. */
  41965. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  41966. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41967. private _selectNode;
  41968. /**
  41969. * Updates the bounding box information for the Gizmo
  41970. */
  41971. updateBoundingBox(): void;
  41972. private _updateRotationSpheres;
  41973. private _updateScaleBoxes;
  41974. /**
  41975. * Enables rotation on the specified axis and disables rotation on the others
  41976. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  41977. */
  41978. setEnabledRotationAxis(axis: string): void;
  41979. /**
  41980. * Enables/disables scaling
  41981. * @param enable if scaling should be enabled
  41982. */
  41983. setEnabledScaling(enable: boolean): void;
  41984. private _updateDummy;
  41985. /**
  41986. * Enables a pointer drag behavior on the bounding box of the gizmo
  41987. */
  41988. enableDragBehavior(): void;
  41989. /**
  41990. * Disposes of the gizmo
  41991. */
  41992. dispose(): void;
  41993. /**
  41994. * 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)
  41995. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  41996. * @returns the bounding box mesh with the passed in mesh as a child
  41997. */
  41998. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  41999. /**
  42000. * CustomMeshes are not supported by this gizmo
  42001. * @param mesh The mesh to replace the default mesh of the gizmo
  42002. */
  42003. setCustomMesh(mesh: Mesh): void;
  42004. }
  42005. }
  42006. declare module BABYLON {
  42007. /**
  42008. * Single plane rotation gizmo
  42009. */
  42010. export class PlaneRotationGizmo extends Gizmo {
  42011. /**
  42012. * Drag behavior responsible for the gizmos dragging interactions
  42013. */
  42014. dragBehavior: PointerDragBehavior;
  42015. private _pointerObserver;
  42016. /**
  42017. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  42018. */
  42019. snapDistance: number;
  42020. /**
  42021. * Event that fires each time the gizmo snaps to a new location.
  42022. * * snapDistance is the the change in distance
  42023. */
  42024. onSnapObservable: Observable<{
  42025. snapDistance: number;
  42026. }>;
  42027. /**
  42028. * Creates a PlaneRotationGizmo
  42029. * @param gizmoLayer The utility layer the gizmo will be added to
  42030. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  42031. * @param color The color of the gizmo
  42032. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42033. */
  42034. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42035. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42036. /**
  42037. * Disposes of the gizmo
  42038. */
  42039. dispose(): void;
  42040. }
  42041. }
  42042. declare module BABYLON {
  42043. /**
  42044. * Gizmo that enables rotating a mesh along 3 axis
  42045. */
  42046. export class RotationGizmo extends Gizmo {
  42047. /**
  42048. * Internal gizmo used for interactions on the x axis
  42049. */
  42050. xGizmo: PlaneRotationGizmo;
  42051. /**
  42052. * Internal gizmo used for interactions on the y axis
  42053. */
  42054. yGizmo: PlaneRotationGizmo;
  42055. /**
  42056. * Internal gizmo used for interactions on the z axis
  42057. */
  42058. zGizmo: PlaneRotationGizmo;
  42059. /** Fires an event when any of it's sub gizmos are dragged */
  42060. onDragStartObservable: Observable<{}>;
  42061. /** Fires an event when any of it's sub gizmos are released from dragging */
  42062. onDragEndObservable: Observable<{}>;
  42063. attachedMesh: Nullable<AbstractMesh>;
  42064. /**
  42065. * Creates a RotationGizmo
  42066. * @param gizmoLayer The utility layer the gizmo will be added to
  42067. * @param tessellation Amount of tessellation to be used when creating rotation circles
  42068. */
  42069. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  42070. updateGizmoRotationToMatchAttachedMesh: boolean;
  42071. /**
  42072. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42073. */
  42074. snapDistance: number;
  42075. /**
  42076. * Ratio for the scale of the gizmo (Default: 1)
  42077. */
  42078. scaleRatio: number;
  42079. /**
  42080. * Disposes of the gizmo
  42081. */
  42082. dispose(): void;
  42083. /**
  42084. * CustomMeshes are not supported by this gizmo
  42085. * @param mesh The mesh to replace the default mesh of the gizmo
  42086. */
  42087. setCustomMesh(mesh: Mesh): void;
  42088. }
  42089. }
  42090. declare module BABYLON {
  42091. /**
  42092. * Gizmo that enables dragging a mesh along 3 axis
  42093. */
  42094. export class PositionGizmo extends Gizmo {
  42095. /**
  42096. * Internal gizmo used for interactions on the x axis
  42097. */
  42098. xGizmo: AxisDragGizmo;
  42099. /**
  42100. * Internal gizmo used for interactions on the y axis
  42101. */
  42102. yGizmo: AxisDragGizmo;
  42103. /**
  42104. * Internal gizmo used for interactions on the z axis
  42105. */
  42106. zGizmo: AxisDragGizmo;
  42107. /** Fires an event when any of it's sub gizmos are dragged */
  42108. onDragStartObservable: Observable<{}>;
  42109. /** Fires an event when any of it's sub gizmos are released from dragging */
  42110. onDragEndObservable: Observable<{}>;
  42111. attachedMesh: Nullable<AbstractMesh>;
  42112. /**
  42113. * Creates a PositionGizmo
  42114. * @param gizmoLayer The utility layer the gizmo will be added to
  42115. */
  42116. constructor(gizmoLayer?: UtilityLayerRenderer);
  42117. updateGizmoRotationToMatchAttachedMesh: boolean;
  42118. /**
  42119. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42120. */
  42121. snapDistance: number;
  42122. /**
  42123. * Ratio for the scale of the gizmo (Default: 1)
  42124. */
  42125. scaleRatio: number;
  42126. /**
  42127. * Disposes of the gizmo
  42128. */
  42129. dispose(): void;
  42130. /**
  42131. * CustomMeshes are not supported by this gizmo
  42132. * @param mesh The mesh to replace the default mesh of the gizmo
  42133. */
  42134. setCustomMesh(mesh: Mesh): void;
  42135. }
  42136. }
  42137. declare module BABYLON {
  42138. /**
  42139. * Class containing static functions to help procedurally build meshes
  42140. */
  42141. export class PolyhedronBuilder {
  42142. /**
  42143. * Creates a polyhedron mesh
  42144. * * 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
  42145. * * The parameter `size` (positive float, default 1) sets the polygon size
  42146. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  42147. * * 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`
  42148. * * 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
  42149. * * 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)`)
  42150. * * 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
  42151. * * 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
  42152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42155. * @param name defines the name of the mesh
  42156. * @param options defines the options used to create the mesh
  42157. * @param scene defines the hosting scene
  42158. * @returns the polyhedron mesh
  42159. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  42160. */
  42161. static CreatePolyhedron(name: string, options: {
  42162. type?: number;
  42163. size?: number;
  42164. sizeX?: number;
  42165. sizeY?: number;
  42166. sizeZ?: number;
  42167. custom?: any;
  42168. faceUV?: Vector4[];
  42169. faceColors?: Color4[];
  42170. flat?: boolean;
  42171. updatable?: boolean;
  42172. sideOrientation?: number;
  42173. frontUVs?: Vector4;
  42174. backUVs?: Vector4;
  42175. }, scene?: Nullable<Scene>): Mesh;
  42176. }
  42177. }
  42178. declare module BABYLON {
  42179. /**
  42180. * Gizmo that enables scaling a mesh along 3 axis
  42181. */
  42182. export class ScaleGizmo extends Gizmo {
  42183. /**
  42184. * Internal gizmo used for interactions on the x axis
  42185. */
  42186. xGizmo: AxisScaleGizmo;
  42187. /**
  42188. * Internal gizmo used for interactions on the y axis
  42189. */
  42190. yGizmo: AxisScaleGizmo;
  42191. /**
  42192. * Internal gizmo used for interactions on the z axis
  42193. */
  42194. zGizmo: AxisScaleGizmo;
  42195. /**
  42196. * Internal gizmo used to scale all axis equally
  42197. */
  42198. uniformScaleGizmo: AxisScaleGizmo;
  42199. /** Fires an event when any of it's sub gizmos are dragged */
  42200. onDragStartObservable: Observable<{}>;
  42201. /** Fires an event when any of it's sub gizmos are released from dragging */
  42202. onDragEndObservable: Observable<{}>;
  42203. attachedMesh: Nullable<AbstractMesh>;
  42204. /**
  42205. * Creates a ScaleGizmo
  42206. * @param gizmoLayer The utility layer the gizmo will be added to
  42207. */
  42208. constructor(gizmoLayer?: UtilityLayerRenderer);
  42209. updateGizmoRotationToMatchAttachedMesh: boolean;
  42210. /**
  42211. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42212. */
  42213. snapDistance: number;
  42214. /**
  42215. * Ratio for the scale of the gizmo (Default: 1)
  42216. */
  42217. scaleRatio: number;
  42218. /**
  42219. * Disposes of the gizmo
  42220. */
  42221. dispose(): void;
  42222. }
  42223. }
  42224. declare module BABYLON {
  42225. /**
  42226. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  42227. */
  42228. export class GizmoManager implements IDisposable {
  42229. private scene;
  42230. /**
  42231. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  42232. */
  42233. gizmos: {
  42234. positionGizmo: Nullable<PositionGizmo>;
  42235. rotationGizmo: Nullable<RotationGizmo>;
  42236. scaleGizmo: Nullable<ScaleGizmo>;
  42237. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  42238. };
  42239. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  42240. clearGizmoOnEmptyPointerEvent: boolean;
  42241. /** Fires an event when the manager is attached to a mesh */
  42242. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  42243. private _gizmosEnabled;
  42244. private _pointerObserver;
  42245. private _attachedMesh;
  42246. private _boundingBoxColor;
  42247. private _defaultUtilityLayer;
  42248. private _defaultKeepDepthUtilityLayer;
  42249. /**
  42250. * When bounding box gizmo is enabled, this can be used to track drag/end events
  42251. */
  42252. boundingBoxDragBehavior: SixDofDragBehavior;
  42253. /**
  42254. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  42255. */
  42256. attachableMeshes: Nullable<Array<AbstractMesh>>;
  42257. /**
  42258. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  42259. */
  42260. usePointerToAttachGizmos: boolean;
  42261. /**
  42262. * Instatiates a gizmo manager
  42263. * @param scene the scene to overlay the gizmos on top of
  42264. */
  42265. constructor(scene: Scene);
  42266. /**
  42267. * Attaches a set of gizmos to the specified mesh
  42268. * @param mesh The mesh the gizmo's should be attached to
  42269. */
  42270. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  42271. /**
  42272. * If the position gizmo is enabled
  42273. */
  42274. positionGizmoEnabled: boolean;
  42275. /**
  42276. * If the rotation gizmo is enabled
  42277. */
  42278. rotationGizmoEnabled: boolean;
  42279. /**
  42280. * If the scale gizmo is enabled
  42281. */
  42282. scaleGizmoEnabled: boolean;
  42283. /**
  42284. * If the boundingBox gizmo is enabled
  42285. */
  42286. boundingBoxGizmoEnabled: boolean;
  42287. /**
  42288. * Disposes of the gizmo manager
  42289. */
  42290. dispose(): void;
  42291. }
  42292. }
  42293. declare module BABYLON {
  42294. /**
  42295. * A directional light is defined by a direction (what a surprise!).
  42296. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  42297. * 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.
  42298. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42299. */
  42300. export class DirectionalLight extends ShadowLight {
  42301. private _shadowFrustumSize;
  42302. /**
  42303. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  42304. */
  42305. /**
  42306. * Specifies a fix frustum size for the shadow generation.
  42307. */
  42308. shadowFrustumSize: number;
  42309. private _shadowOrthoScale;
  42310. /**
  42311. * Gets the shadow projection scale against the optimal computed one.
  42312. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42313. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42314. */
  42315. /**
  42316. * Sets the shadow projection scale against the optimal computed one.
  42317. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  42318. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  42319. */
  42320. shadowOrthoScale: number;
  42321. /**
  42322. * Automatically compute the projection matrix to best fit (including all the casters)
  42323. * on each frame.
  42324. */
  42325. autoUpdateExtends: boolean;
  42326. private _orthoLeft;
  42327. private _orthoRight;
  42328. private _orthoTop;
  42329. private _orthoBottom;
  42330. /**
  42331. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  42332. * The directional light is emitted from everywhere in the given direction.
  42333. * It can cast shadows.
  42334. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42335. * @param name The friendly name of the light
  42336. * @param direction The direction of the light
  42337. * @param scene The scene the light belongs to
  42338. */
  42339. constructor(name: string, direction: Vector3, scene: Scene);
  42340. /**
  42341. * Returns the string "DirectionalLight".
  42342. * @return The class name
  42343. */
  42344. getClassName(): string;
  42345. /**
  42346. * Returns the integer 1.
  42347. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42348. */
  42349. getTypeID(): number;
  42350. /**
  42351. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  42352. * Returns the DirectionalLight Shadow projection matrix.
  42353. */
  42354. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42355. /**
  42356. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  42357. * Returns the DirectionalLight Shadow projection matrix.
  42358. */
  42359. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  42360. /**
  42361. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  42362. * Returns the DirectionalLight Shadow projection matrix.
  42363. */
  42364. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42365. protected _buildUniformLayout(): void;
  42366. /**
  42367. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  42368. * @param effect The effect to update
  42369. * @param lightIndex The index of the light in the effect to update
  42370. * @returns The directional light
  42371. */
  42372. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  42373. /**
  42374. * Gets the minZ used for shadow according to both the scene and the light.
  42375. *
  42376. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42377. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42378. * @param activeCamera The camera we are returning the min for
  42379. * @returns the depth min z
  42380. */
  42381. getDepthMinZ(activeCamera: Camera): number;
  42382. /**
  42383. * Gets the maxZ used for shadow according to both the scene and the light.
  42384. *
  42385. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  42386. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  42387. * @param activeCamera The camera we are returning the max for
  42388. * @returns the depth max z
  42389. */
  42390. getDepthMaxZ(activeCamera: Camera): number;
  42391. /**
  42392. * Prepares the list of defines specific to the light type.
  42393. * @param defines the list of defines
  42394. * @param lightIndex defines the index of the light for the effect
  42395. */
  42396. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42397. }
  42398. }
  42399. declare module BABYLON {
  42400. /**
  42401. * Class containing static functions to help procedurally build meshes
  42402. */
  42403. export class HemisphereBuilder {
  42404. /**
  42405. * Creates a hemisphere mesh
  42406. * @param name defines the name of the mesh
  42407. * @param options defines the options used to create the mesh
  42408. * @param scene defines the hosting scene
  42409. * @returns the hemisphere mesh
  42410. */
  42411. static CreateHemisphere(name: string, options: {
  42412. segments?: number;
  42413. diameter?: number;
  42414. sideOrientation?: number;
  42415. }, scene: any): Mesh;
  42416. }
  42417. }
  42418. declare module BABYLON {
  42419. /**
  42420. * A spot light is defined by a position, a direction, an angle, and an exponent.
  42421. * These values define a cone of light starting from the position, emitting toward the direction.
  42422. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  42423. * and the exponent defines the speed of the decay of the light with distance (reach).
  42424. * Documentation: https://doc.babylonjs.com/babylon101/lights
  42425. */
  42426. export class SpotLight extends ShadowLight {
  42427. private _angle;
  42428. private _innerAngle;
  42429. private _cosHalfAngle;
  42430. private _lightAngleScale;
  42431. private _lightAngleOffset;
  42432. /**
  42433. * Gets the cone angle of the spot light in Radians.
  42434. */
  42435. /**
  42436. * Sets the cone angle of the spot light in Radians.
  42437. */
  42438. angle: number;
  42439. /**
  42440. * Only used in gltf falloff mode, this defines the angle where
  42441. * the directional falloff will start before cutting at angle which could be seen
  42442. * as outer angle.
  42443. */
  42444. /**
  42445. * Only used in gltf falloff mode, this defines the angle where
  42446. * the directional falloff will start before cutting at angle which could be seen
  42447. * as outer angle.
  42448. */
  42449. innerAngle: number;
  42450. private _shadowAngleScale;
  42451. /**
  42452. * Allows scaling the angle of the light for shadow generation only.
  42453. */
  42454. /**
  42455. * Allows scaling the angle of the light for shadow generation only.
  42456. */
  42457. shadowAngleScale: number;
  42458. /**
  42459. * The light decay speed with the distance from the emission spot.
  42460. */
  42461. exponent: number;
  42462. private _projectionTextureMatrix;
  42463. /**
  42464. * Allows reading the projecton texture
  42465. */
  42466. readonly projectionTextureMatrix: Matrix;
  42467. protected _projectionTextureLightNear: number;
  42468. /**
  42469. * Gets the near clip of the Spotlight for texture projection.
  42470. */
  42471. /**
  42472. * Sets the near clip of the Spotlight for texture projection.
  42473. */
  42474. projectionTextureLightNear: number;
  42475. protected _projectionTextureLightFar: number;
  42476. /**
  42477. * Gets the far clip of the Spotlight for texture projection.
  42478. */
  42479. /**
  42480. * Sets the far clip of the Spotlight for texture projection.
  42481. */
  42482. projectionTextureLightFar: number;
  42483. protected _projectionTextureUpDirection: Vector3;
  42484. /**
  42485. * Gets the Up vector of the Spotlight for texture projection.
  42486. */
  42487. /**
  42488. * Sets the Up vector of the Spotlight for texture projection.
  42489. */
  42490. projectionTextureUpDirection: Vector3;
  42491. private _projectionTexture;
  42492. /**
  42493. * Gets the projection texture of the light.
  42494. */
  42495. /**
  42496. * Sets the projection texture of the light.
  42497. */
  42498. projectionTexture: Nullable<BaseTexture>;
  42499. private _projectionTextureViewLightDirty;
  42500. private _projectionTextureProjectionLightDirty;
  42501. private _projectionTextureDirty;
  42502. private _projectionTextureViewTargetVector;
  42503. private _projectionTextureViewLightMatrix;
  42504. private _projectionTextureProjectionLightMatrix;
  42505. private _projectionTextureScalingMatrix;
  42506. /**
  42507. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  42508. * It can cast shadows.
  42509. * Documentation : https://doc.babylonjs.com/babylon101/lights
  42510. * @param name The light friendly name
  42511. * @param position The position of the spot light in the scene
  42512. * @param direction The direction of the light in the scene
  42513. * @param angle The cone angle of the light in Radians
  42514. * @param exponent The light decay speed with the distance from the emission spot
  42515. * @param scene The scene the lights belongs to
  42516. */
  42517. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  42518. /**
  42519. * Returns the string "SpotLight".
  42520. * @returns the class name
  42521. */
  42522. getClassName(): string;
  42523. /**
  42524. * Returns the integer 2.
  42525. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  42526. */
  42527. getTypeID(): number;
  42528. /**
  42529. * Overrides the direction setter to recompute the projection texture view light Matrix.
  42530. */
  42531. protected _setDirection(value: Vector3): void;
  42532. /**
  42533. * Overrides the position setter to recompute the projection texture view light Matrix.
  42534. */
  42535. protected _setPosition(value: Vector3): void;
  42536. /**
  42537. * 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.
  42538. * Returns the SpotLight.
  42539. */
  42540. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  42541. protected _computeProjectionTextureViewLightMatrix(): void;
  42542. protected _computeProjectionTextureProjectionLightMatrix(): void;
  42543. /**
  42544. * Main function for light texture projection matrix computing.
  42545. */
  42546. protected _computeProjectionTextureMatrix(): void;
  42547. protected _buildUniformLayout(): void;
  42548. private _computeAngleValues;
  42549. /**
  42550. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  42551. * @param effect The effect to update
  42552. * @param lightIndex The index of the light in the effect to update
  42553. * @returns The spot light
  42554. */
  42555. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  42556. /**
  42557. * Disposes the light and the associated resources.
  42558. */
  42559. dispose(): void;
  42560. /**
  42561. * Prepares the list of defines specific to the light type.
  42562. * @param defines the list of defines
  42563. * @param lightIndex defines the index of the light for the effect
  42564. */
  42565. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  42566. }
  42567. }
  42568. declare module BABYLON {
  42569. /**
  42570. * Gizmo that enables viewing a light
  42571. */
  42572. export class LightGizmo extends Gizmo {
  42573. private _lightMesh;
  42574. private _material;
  42575. private cachedPosition;
  42576. private cachedForward;
  42577. /**
  42578. * Creates a LightGizmo
  42579. * @param gizmoLayer The utility layer the gizmo will be added to
  42580. */
  42581. constructor(gizmoLayer?: UtilityLayerRenderer);
  42582. private _light;
  42583. /**
  42584. * The light that the gizmo is attached to
  42585. */
  42586. light: Nullable<Light>;
  42587. /**
  42588. * @hidden
  42589. * Updates the gizmo to match the attached mesh's position/rotation
  42590. */
  42591. protected _update(): void;
  42592. private static _Scale;
  42593. /**
  42594. * Creates the lines for a light mesh
  42595. */
  42596. private static _createLightLines;
  42597. /**
  42598. * Disposes of the light gizmo
  42599. */
  42600. dispose(): void;
  42601. private static _CreateHemisphericLightMesh;
  42602. private static _CreatePointLightMesh;
  42603. private static _CreateSpotLightMesh;
  42604. private static _CreateDirectionalLightMesh;
  42605. }
  42606. }
  42607. declare module BABYLON {
  42608. /** @hidden */
  42609. export var backgroundFragmentDeclaration: {
  42610. name: string;
  42611. shader: string;
  42612. };
  42613. }
  42614. declare module BABYLON {
  42615. /** @hidden */
  42616. export var backgroundUboDeclaration: {
  42617. name: string;
  42618. shader: string;
  42619. };
  42620. }
  42621. declare module BABYLON {
  42622. /** @hidden */
  42623. export var backgroundPixelShader: {
  42624. name: string;
  42625. shader: string;
  42626. };
  42627. }
  42628. declare module BABYLON {
  42629. /** @hidden */
  42630. export var backgroundVertexDeclaration: {
  42631. name: string;
  42632. shader: string;
  42633. };
  42634. }
  42635. declare module BABYLON {
  42636. /** @hidden */
  42637. export var backgroundVertexShader: {
  42638. name: string;
  42639. shader: string;
  42640. };
  42641. }
  42642. declare module BABYLON {
  42643. /**
  42644. * Background material used to create an efficient environement around your scene.
  42645. */
  42646. export class BackgroundMaterial extends PushMaterial {
  42647. /**
  42648. * Standard reflectance value at parallel view angle.
  42649. */
  42650. static StandardReflectance0: number;
  42651. /**
  42652. * Standard reflectance value at grazing angle.
  42653. */
  42654. static StandardReflectance90: number;
  42655. protected _primaryColor: Color3;
  42656. /**
  42657. * Key light Color (multiply against the environement texture)
  42658. */
  42659. primaryColor: Color3;
  42660. protected __perceptualColor: Nullable<Color3>;
  42661. /**
  42662. * Experimental Internal Use Only.
  42663. *
  42664. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  42665. * This acts as a helper to set the primary color to a more "human friendly" value.
  42666. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  42667. * output color as close as possible from the chosen value.
  42668. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  42669. * part of lighting setup.)
  42670. */ private _perceptualColor: Nullable<Color3>;
  42671. protected _primaryColorShadowLevel: float;
  42672. /**
  42673. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  42674. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  42675. */
  42676. primaryColorShadowLevel: float;
  42677. protected _primaryColorHighlightLevel: float;
  42678. /**
  42679. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  42680. * The primary color is used at the level chosen to define what the white area would look.
  42681. */
  42682. primaryColorHighlightLevel: float;
  42683. protected _reflectionTexture: Nullable<BaseTexture>;
  42684. /**
  42685. * Reflection Texture used in the material.
  42686. * Should be author in a specific way for the best result (refer to the documentation).
  42687. */
  42688. reflectionTexture: Nullable<BaseTexture>;
  42689. protected _reflectionBlur: float;
  42690. /**
  42691. * Reflection Texture level of blur.
  42692. *
  42693. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  42694. * texture twice.
  42695. */
  42696. reflectionBlur: float;
  42697. protected _diffuseTexture: Nullable<BaseTexture>;
  42698. /**
  42699. * Diffuse Texture used in the material.
  42700. * Should be author in a specific way for the best result (refer to the documentation).
  42701. */
  42702. diffuseTexture: Nullable<BaseTexture>;
  42703. protected _shadowLights: Nullable<IShadowLight[]>;
  42704. /**
  42705. * Specify the list of lights casting shadow on the material.
  42706. * All scene shadow lights will be included if null.
  42707. */
  42708. shadowLights: Nullable<IShadowLight[]>;
  42709. protected _shadowLevel: float;
  42710. /**
  42711. * Helps adjusting the shadow to a softer level if required.
  42712. * 0 means black shadows and 1 means no shadows.
  42713. */
  42714. shadowLevel: float;
  42715. protected _sceneCenter: Vector3;
  42716. /**
  42717. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  42718. * It is usually zero but might be interesting to modify according to your setup.
  42719. */
  42720. sceneCenter: Vector3;
  42721. protected _opacityFresnel: boolean;
  42722. /**
  42723. * This helps specifying that the material is falling off to the sky box at grazing angle.
  42724. * This helps ensuring a nice transition when the camera goes under the ground.
  42725. */
  42726. opacityFresnel: boolean;
  42727. protected _reflectionFresnel: boolean;
  42728. /**
  42729. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  42730. * This helps adding a mirror texture on the ground.
  42731. */
  42732. reflectionFresnel: boolean;
  42733. protected _reflectionFalloffDistance: number;
  42734. /**
  42735. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  42736. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  42737. */
  42738. reflectionFalloffDistance: number;
  42739. protected _reflectionAmount: number;
  42740. /**
  42741. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  42742. */
  42743. reflectionAmount: number;
  42744. protected _reflectionReflectance0: number;
  42745. /**
  42746. * This specifies the weight of the reflection at grazing angle.
  42747. */
  42748. reflectionReflectance0: number;
  42749. protected _reflectionReflectance90: number;
  42750. /**
  42751. * This specifies the weight of the reflection at a perpendicular point of view.
  42752. */
  42753. reflectionReflectance90: number;
  42754. /**
  42755. * Sets the reflection reflectance fresnel values according to the default standard
  42756. * empirically know to work well :-)
  42757. */
  42758. reflectionStandardFresnelWeight: number;
  42759. protected _useRGBColor: boolean;
  42760. /**
  42761. * Helps to directly use the maps channels instead of their level.
  42762. */
  42763. useRGBColor: boolean;
  42764. protected _enableNoise: boolean;
  42765. /**
  42766. * This helps reducing the banding effect that could occur on the background.
  42767. */
  42768. enableNoise: boolean;
  42769. /**
  42770. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  42771. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  42772. * Recommended to be keep at 1.0 except for special cases.
  42773. */
  42774. fovMultiplier: number;
  42775. private _fovMultiplier;
  42776. /**
  42777. * Enable the FOV adjustment feature controlled by fovMultiplier.
  42778. */
  42779. useEquirectangularFOV: boolean;
  42780. private _maxSimultaneousLights;
  42781. /**
  42782. * Number of Simultaneous lights allowed on the material.
  42783. */
  42784. maxSimultaneousLights: int;
  42785. /**
  42786. * Default configuration related to image processing available in the Background Material.
  42787. */
  42788. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42789. /**
  42790. * Keep track of the image processing observer to allow dispose and replace.
  42791. */
  42792. private _imageProcessingObserver;
  42793. /**
  42794. * Attaches a new image processing configuration to the PBR Material.
  42795. * @param configuration (if null the scene configuration will be use)
  42796. */
  42797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  42798. /**
  42799. * Gets the image processing configuration used either in this material.
  42800. */
  42801. /**
  42802. * Sets the Default image processing configuration used either in the this material.
  42803. *
  42804. * If sets to null, the scene one is in use.
  42805. */
  42806. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  42807. /**
  42808. * Gets wether the color curves effect is enabled.
  42809. */
  42810. /**
  42811. * Sets wether the color curves effect is enabled.
  42812. */
  42813. cameraColorCurvesEnabled: boolean;
  42814. /**
  42815. * Gets wether the color grading effect is enabled.
  42816. */
  42817. /**
  42818. * Gets wether the color grading effect is enabled.
  42819. */
  42820. cameraColorGradingEnabled: boolean;
  42821. /**
  42822. * Gets wether tonemapping is enabled or not.
  42823. */
  42824. /**
  42825. * Sets wether tonemapping is enabled or not
  42826. */
  42827. cameraToneMappingEnabled: boolean;
  42828. /**
  42829. * The camera exposure used on this material.
  42830. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42831. * This corresponds to a photographic exposure.
  42832. */
  42833. /**
  42834. * The camera exposure used on this material.
  42835. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  42836. * This corresponds to a photographic exposure.
  42837. */
  42838. cameraExposure: float;
  42839. /**
  42840. * Gets The camera contrast used on this material.
  42841. */
  42842. /**
  42843. * Sets The camera contrast used on this material.
  42844. */
  42845. cameraContrast: float;
  42846. /**
  42847. * Gets the Color Grading 2D Lookup Texture.
  42848. */
  42849. /**
  42850. * Sets the Color Grading 2D Lookup Texture.
  42851. */
  42852. cameraColorGradingTexture: Nullable<BaseTexture>;
  42853. /**
  42854. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42855. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42856. * 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;
  42857. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42858. */
  42859. /**
  42860. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  42861. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  42862. * 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;
  42863. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  42864. */
  42865. cameraColorCurves: Nullable<ColorCurves>;
  42866. /**
  42867. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  42868. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  42869. */
  42870. switchToBGR: boolean;
  42871. private _renderTargets;
  42872. private _reflectionControls;
  42873. private _white;
  42874. private _primaryShadowColor;
  42875. private _primaryHighlightColor;
  42876. /**
  42877. * Instantiates a Background Material in the given scene
  42878. * @param name The friendly name of the material
  42879. * @param scene The scene to add the material to
  42880. */
  42881. constructor(name: string, scene: Scene);
  42882. /**
  42883. * Gets a boolean indicating that current material needs to register RTT
  42884. */
  42885. readonly hasRenderTargetTextures: boolean;
  42886. /**
  42887. * The entire material has been created in order to prevent overdraw.
  42888. * @returns false
  42889. */
  42890. needAlphaTesting(): boolean;
  42891. /**
  42892. * The entire material has been created in order to prevent overdraw.
  42893. * @returns true if blending is enable
  42894. */
  42895. needAlphaBlending(): boolean;
  42896. /**
  42897. * Checks wether the material is ready to be rendered for a given mesh.
  42898. * @param mesh The mesh to render
  42899. * @param subMesh The submesh to check against
  42900. * @param useInstances Specify wether or not the material is used with instances
  42901. * @returns true if all the dependencies are ready (Textures, Effects...)
  42902. */
  42903. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42904. /**
  42905. * Compute the primary color according to the chosen perceptual color.
  42906. */
  42907. private _computePrimaryColorFromPerceptualColor;
  42908. /**
  42909. * Compute the highlights and shadow colors according to their chosen levels.
  42910. */
  42911. private _computePrimaryColors;
  42912. /**
  42913. * Build the uniform buffer used in the material.
  42914. */
  42915. buildUniformLayout(): void;
  42916. /**
  42917. * Unbind the material.
  42918. */
  42919. unbind(): void;
  42920. /**
  42921. * Bind only the world matrix to the material.
  42922. * @param world The world matrix to bind.
  42923. */
  42924. bindOnlyWorldMatrix(world: Matrix): void;
  42925. /**
  42926. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  42927. * @param world The world matrix to bind.
  42928. * @param subMesh The submesh to bind for.
  42929. */
  42930. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42931. /**
  42932. * Dispose the material.
  42933. * @param forceDisposeEffect Force disposal of the associated effect.
  42934. * @param forceDisposeTextures Force disposal of the associated textures.
  42935. */
  42936. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42937. /**
  42938. * Clones the material.
  42939. * @param name The cloned name.
  42940. * @returns The cloned material.
  42941. */
  42942. clone(name: string): BackgroundMaterial;
  42943. /**
  42944. * Serializes the current material to its JSON representation.
  42945. * @returns The JSON representation.
  42946. */
  42947. serialize(): any;
  42948. /**
  42949. * Gets the class name of the material
  42950. * @returns "BackgroundMaterial"
  42951. */
  42952. getClassName(): string;
  42953. /**
  42954. * Parse a JSON input to create back a background material.
  42955. * @param source The JSON data to parse
  42956. * @param scene The scene to create the parsed material in
  42957. * @param rootUrl The root url of the assets the material depends upon
  42958. * @returns the instantiated BackgroundMaterial.
  42959. */
  42960. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  42961. }
  42962. }
  42963. declare module BABYLON {
  42964. /**
  42965. * Represents the different options available during the creation of
  42966. * a Environment helper.
  42967. *
  42968. * This can control the default ground, skybox and image processing setup of your scene.
  42969. */
  42970. export interface IEnvironmentHelperOptions {
  42971. /**
  42972. * Specifies wether or not to create a ground.
  42973. * True by default.
  42974. */
  42975. createGround: boolean;
  42976. /**
  42977. * Specifies the ground size.
  42978. * 15 by default.
  42979. */
  42980. groundSize: number;
  42981. /**
  42982. * The texture used on the ground for the main color.
  42983. * Comes from the BabylonJS CDN by default.
  42984. *
  42985. * Remarks: Can be either a texture or a url.
  42986. */
  42987. groundTexture: string | BaseTexture;
  42988. /**
  42989. * The color mixed in the ground texture by default.
  42990. * BabylonJS clearColor by default.
  42991. */
  42992. groundColor: Color3;
  42993. /**
  42994. * Specifies the ground opacity.
  42995. * 1 by default.
  42996. */
  42997. groundOpacity: number;
  42998. /**
  42999. * Enables the ground to receive shadows.
  43000. * True by default.
  43001. */
  43002. enableGroundShadow: boolean;
  43003. /**
  43004. * Helps preventing the shadow to be fully black on the ground.
  43005. * 0.5 by default.
  43006. */
  43007. groundShadowLevel: number;
  43008. /**
  43009. * Creates a mirror texture attach to the ground.
  43010. * false by default.
  43011. */
  43012. enableGroundMirror: boolean;
  43013. /**
  43014. * Specifies the ground mirror size ratio.
  43015. * 0.3 by default as the default kernel is 64.
  43016. */
  43017. groundMirrorSizeRatio: number;
  43018. /**
  43019. * Specifies the ground mirror blur kernel size.
  43020. * 64 by default.
  43021. */
  43022. groundMirrorBlurKernel: number;
  43023. /**
  43024. * Specifies the ground mirror visibility amount.
  43025. * 1 by default
  43026. */
  43027. groundMirrorAmount: number;
  43028. /**
  43029. * Specifies the ground mirror reflectance weight.
  43030. * This uses the standard weight of the background material to setup the fresnel effect
  43031. * of the mirror.
  43032. * 1 by default.
  43033. */
  43034. groundMirrorFresnelWeight: number;
  43035. /**
  43036. * Specifies the ground mirror Falloff distance.
  43037. * This can helps reducing the size of the reflection.
  43038. * 0 by Default.
  43039. */
  43040. groundMirrorFallOffDistance: number;
  43041. /**
  43042. * Specifies the ground mirror texture type.
  43043. * Unsigned Int by Default.
  43044. */
  43045. groundMirrorTextureType: number;
  43046. /**
  43047. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  43048. * the shown objects.
  43049. */
  43050. groundYBias: number;
  43051. /**
  43052. * Specifies wether or not to create a skybox.
  43053. * True by default.
  43054. */
  43055. createSkybox: boolean;
  43056. /**
  43057. * Specifies the skybox size.
  43058. * 20 by default.
  43059. */
  43060. skyboxSize: number;
  43061. /**
  43062. * The texture used on the skybox for the main color.
  43063. * Comes from the BabylonJS CDN by default.
  43064. *
  43065. * Remarks: Can be either a texture or a url.
  43066. */
  43067. skyboxTexture: string | BaseTexture;
  43068. /**
  43069. * The color mixed in the skybox texture by default.
  43070. * BabylonJS clearColor by default.
  43071. */
  43072. skyboxColor: Color3;
  43073. /**
  43074. * The background rotation around the Y axis of the scene.
  43075. * This helps aligning the key lights of your scene with the background.
  43076. * 0 by default.
  43077. */
  43078. backgroundYRotation: number;
  43079. /**
  43080. * Compute automatically the size of the elements to best fit with the scene.
  43081. */
  43082. sizeAuto: boolean;
  43083. /**
  43084. * Default position of the rootMesh if autoSize is not true.
  43085. */
  43086. rootPosition: Vector3;
  43087. /**
  43088. * Sets up the image processing in the scene.
  43089. * true by default.
  43090. */
  43091. setupImageProcessing: boolean;
  43092. /**
  43093. * The texture used as your environment texture in the scene.
  43094. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  43095. *
  43096. * Remarks: Can be either a texture or a url.
  43097. */
  43098. environmentTexture: string | BaseTexture;
  43099. /**
  43100. * The value of the exposure to apply to the scene.
  43101. * 0.6 by default if setupImageProcessing is true.
  43102. */
  43103. cameraExposure: number;
  43104. /**
  43105. * The value of the contrast to apply to the scene.
  43106. * 1.6 by default if setupImageProcessing is true.
  43107. */
  43108. cameraContrast: number;
  43109. /**
  43110. * Specifies wether or not tonemapping should be enabled in the scene.
  43111. * true by default if setupImageProcessing is true.
  43112. */
  43113. toneMappingEnabled: boolean;
  43114. }
  43115. /**
  43116. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  43117. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  43118. * It also helps with the default setup of your imageProcessing configuration.
  43119. */
  43120. export class EnvironmentHelper {
  43121. /**
  43122. * Default ground texture URL.
  43123. */
  43124. private static _groundTextureCDNUrl;
  43125. /**
  43126. * Default skybox texture URL.
  43127. */
  43128. private static _skyboxTextureCDNUrl;
  43129. /**
  43130. * Default environment texture URL.
  43131. */
  43132. private static _environmentTextureCDNUrl;
  43133. /**
  43134. * Creates the default options for the helper.
  43135. */
  43136. private static _getDefaultOptions;
  43137. private _rootMesh;
  43138. /**
  43139. * Gets the root mesh created by the helper.
  43140. */
  43141. readonly rootMesh: Mesh;
  43142. private _skybox;
  43143. /**
  43144. * Gets the skybox created by the helper.
  43145. */
  43146. readonly skybox: Nullable<Mesh>;
  43147. private _skyboxTexture;
  43148. /**
  43149. * Gets the skybox texture created by the helper.
  43150. */
  43151. readonly skyboxTexture: Nullable<BaseTexture>;
  43152. private _skyboxMaterial;
  43153. /**
  43154. * Gets the skybox material created by the helper.
  43155. */
  43156. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  43157. private _ground;
  43158. /**
  43159. * Gets the ground mesh created by the helper.
  43160. */
  43161. readonly ground: Nullable<Mesh>;
  43162. private _groundTexture;
  43163. /**
  43164. * Gets the ground texture created by the helper.
  43165. */
  43166. readonly groundTexture: Nullable<BaseTexture>;
  43167. private _groundMirror;
  43168. /**
  43169. * Gets the ground mirror created by the helper.
  43170. */
  43171. readonly groundMirror: Nullable<MirrorTexture>;
  43172. /**
  43173. * Gets the ground mirror render list to helps pushing the meshes
  43174. * you wish in the ground reflection.
  43175. */
  43176. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  43177. private _groundMaterial;
  43178. /**
  43179. * Gets the ground material created by the helper.
  43180. */
  43181. readonly groundMaterial: Nullable<BackgroundMaterial>;
  43182. /**
  43183. * Stores the creation options.
  43184. */
  43185. private readonly _scene;
  43186. private _options;
  43187. /**
  43188. * This observable will be notified with any error during the creation of the environment,
  43189. * mainly texture creation errors.
  43190. */
  43191. onErrorObservable: Observable<{
  43192. message?: string;
  43193. exception?: any;
  43194. }>;
  43195. /**
  43196. * constructor
  43197. * @param options Defines the options we want to customize the helper
  43198. * @param scene The scene to add the material to
  43199. */
  43200. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  43201. /**
  43202. * Updates the background according to the new options
  43203. * @param options
  43204. */
  43205. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  43206. /**
  43207. * Sets the primary color of all the available elements.
  43208. * @param color the main color to affect to the ground and the background
  43209. */
  43210. setMainColor(color: Color3): void;
  43211. /**
  43212. * Setup the image processing according to the specified options.
  43213. */
  43214. private _setupImageProcessing;
  43215. /**
  43216. * Setup the environment texture according to the specified options.
  43217. */
  43218. private _setupEnvironmentTexture;
  43219. /**
  43220. * Setup the background according to the specified options.
  43221. */
  43222. private _setupBackground;
  43223. /**
  43224. * Get the scene sizes according to the setup.
  43225. */
  43226. private _getSceneSize;
  43227. /**
  43228. * Setup the ground according to the specified options.
  43229. */
  43230. private _setupGround;
  43231. /**
  43232. * Setup the ground material according to the specified options.
  43233. */
  43234. private _setupGroundMaterial;
  43235. /**
  43236. * Setup the ground diffuse texture according to the specified options.
  43237. */
  43238. private _setupGroundDiffuseTexture;
  43239. /**
  43240. * Setup the ground mirror texture according to the specified options.
  43241. */
  43242. private _setupGroundMirrorTexture;
  43243. /**
  43244. * Setup the ground to receive the mirror texture.
  43245. */
  43246. private _setupMirrorInGroundMaterial;
  43247. /**
  43248. * Setup the skybox according to the specified options.
  43249. */
  43250. private _setupSkybox;
  43251. /**
  43252. * Setup the skybox material according to the specified options.
  43253. */
  43254. private _setupSkyboxMaterial;
  43255. /**
  43256. * Setup the skybox reflection texture according to the specified options.
  43257. */
  43258. private _setupSkyboxReflectionTexture;
  43259. private _errorHandler;
  43260. /**
  43261. * Dispose all the elements created by the Helper.
  43262. */
  43263. dispose(): void;
  43264. }
  43265. }
  43266. declare module BABYLON {
  43267. /**
  43268. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  43269. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  43270. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  43271. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  43272. */
  43273. export class PhotoDome extends TransformNode {
  43274. private _useDirectMapping;
  43275. /**
  43276. * The texture being displayed on the sphere
  43277. */
  43278. protected _photoTexture: Texture;
  43279. /**
  43280. * Gets or sets the texture being displayed on the sphere
  43281. */
  43282. photoTexture: Texture;
  43283. /**
  43284. * Observable raised when an error occured while loading the 360 image
  43285. */
  43286. onLoadErrorObservable: Observable<string>;
  43287. /**
  43288. * The skybox material
  43289. */
  43290. protected _material: BackgroundMaterial;
  43291. /**
  43292. * The surface used for the skybox
  43293. */
  43294. protected _mesh: Mesh;
  43295. /**
  43296. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  43297. * Also see the options.resolution property.
  43298. */
  43299. fovMultiplier: number;
  43300. /**
  43301. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  43302. * @param name Element's name, child elements will append suffixes for their own names.
  43303. * @param urlsOfPhoto defines the url of the photo to display
  43304. * @param options defines an object containing optional or exposed sub element properties
  43305. * @param onError defines a callback called when an error occured while loading the texture
  43306. */
  43307. constructor(name: string, urlOfPhoto: string, options: {
  43308. resolution?: number;
  43309. size?: number;
  43310. useDirectMapping?: boolean;
  43311. faceForward?: boolean;
  43312. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  43313. /**
  43314. * Releases resources associated with this node.
  43315. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  43316. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  43317. */
  43318. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  43319. }
  43320. }
  43321. declare module BABYLON {
  43322. /** @hidden */
  43323. export var rgbdDecodePixelShader: {
  43324. name: string;
  43325. shader: string;
  43326. };
  43327. }
  43328. declare module BABYLON {
  43329. /**
  43330. * Class used to host texture specific utilities
  43331. */
  43332. export class BRDFTextureTools {
  43333. /**
  43334. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  43335. * @param texture the texture to expand.
  43336. */
  43337. private static _ExpandDefaultBRDFTexture;
  43338. /**
  43339. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  43340. * @param scene defines the hosting scene
  43341. * @returns the environment BRDF texture
  43342. */
  43343. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  43344. private static _environmentBRDFBase64Texture;
  43345. }
  43346. }
  43347. declare module BABYLON {
  43348. /**
  43349. * @hidden
  43350. */
  43351. export interface IMaterialClearCoatDefines {
  43352. CLEARCOAT: boolean;
  43353. CLEARCOAT_DEFAULTIOR: boolean;
  43354. CLEARCOAT_TEXTURE: boolean;
  43355. CLEARCOAT_TEXTUREDIRECTUV: number;
  43356. CLEARCOAT_BUMP: boolean;
  43357. CLEARCOAT_BUMPDIRECTUV: number;
  43358. CLEARCOAT_TINT: boolean;
  43359. CLEARCOAT_TINT_TEXTURE: boolean;
  43360. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  43361. /** @hidden */ private _areTexturesDirty: boolean;
  43362. }
  43363. /**
  43364. * Define the code related to the clear coat parameters of the pbr material.
  43365. */
  43366. export class PBRClearCoatConfiguration {
  43367. /**
  43368. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43369. * The default fits with a polyurethane material.
  43370. */
  43371. private static readonly _DefaultIndiceOfRefraction;
  43372. private _isEnabled;
  43373. /**
  43374. * Defines if the clear coat is enabled in the material.
  43375. */
  43376. isEnabled: boolean;
  43377. /**
  43378. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  43379. */
  43380. intensity: number;
  43381. /**
  43382. * Defines the clear coat layer roughness.
  43383. */
  43384. roughness: number;
  43385. private _indiceOfRefraction;
  43386. /**
  43387. * Defines the indice of refraction of the clear coat.
  43388. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  43389. * The default fits with a polyurethane material.
  43390. * Changing the default value is more performance intensive.
  43391. */
  43392. indiceOfRefraction: number;
  43393. private _texture;
  43394. /**
  43395. * Stores the clear coat values in a texture.
  43396. */
  43397. texture: Nullable<BaseTexture>;
  43398. private _bumpTexture;
  43399. /**
  43400. * Define the clear coat specific bump texture.
  43401. */
  43402. bumpTexture: Nullable<BaseTexture>;
  43403. private _isTintEnabled;
  43404. /**
  43405. * Defines if the clear coat tint is enabled in the material.
  43406. */
  43407. isTintEnabled: boolean;
  43408. /**
  43409. * Defines the clear coat tint of the material.
  43410. * This is only use if tint is enabled
  43411. */
  43412. tintColor: Color3;
  43413. /**
  43414. * Defines the distance at which the tint color should be found in the
  43415. * clear coat media.
  43416. * This is only use if tint is enabled
  43417. */
  43418. tintColorAtDistance: number;
  43419. /**
  43420. * Defines the clear coat layer thickness.
  43421. * This is only use if tint is enabled
  43422. */
  43423. tintThickness: number;
  43424. private _tintTexture;
  43425. /**
  43426. * Stores the clear tint values in a texture.
  43427. * rgb is tint
  43428. * a is a thickness factor
  43429. */
  43430. tintTexture: Nullable<BaseTexture>;
  43431. /** @hidden */
  43432. private _internalMarkAllSubMeshesAsTexturesDirty;
  43433. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43434. /**
  43435. * Instantiate a new istance of clear coat configuration.
  43436. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43437. */
  43438. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43439. /**
  43440. * Gets wehter the submesh is ready to be used or not.
  43441. * @param defines the list of "defines" to update.
  43442. * @param scene defines the scene the material belongs to.
  43443. * @param engine defines the engine the material belongs to.
  43444. * @param disableBumpMap defines wether the material disables bump or not.
  43445. * @returns - boolean indicating that the submesh is ready or not.
  43446. */
  43447. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  43448. /**
  43449. * Checks to see if a texture is used in the material.
  43450. * @param defines the list of "defines" to update.
  43451. * @param scene defines the scene to the material belongs to.
  43452. */
  43453. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  43454. /**
  43455. * Binds the material data.
  43456. * @param uniformBuffer defines the Uniform buffer to fill in.
  43457. * @param scene defines the scene the material belongs to.
  43458. * @param engine defines the engine the material belongs to.
  43459. * @param disableBumpMap defines wether the material disables bump or not.
  43460. * @param isFrozen defines wether the material is frozen or not.
  43461. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  43462. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  43463. */
  43464. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  43465. /**
  43466. * Checks to see if a texture is used in the material.
  43467. * @param texture - Base texture to use.
  43468. * @returns - Boolean specifying if a texture is used in the material.
  43469. */
  43470. hasTexture(texture: BaseTexture): boolean;
  43471. /**
  43472. * Returns an array of the actively used textures.
  43473. * @param activeTextures Array of BaseTextures
  43474. */
  43475. getActiveTextures(activeTextures: BaseTexture[]): void;
  43476. /**
  43477. * Returns the animatable textures.
  43478. * @param animatables Array of animatable textures.
  43479. */
  43480. getAnimatables(animatables: IAnimatable[]): void;
  43481. /**
  43482. * Disposes the resources of the material.
  43483. * @param forceDisposeTextures - Forces the disposal of all textures.
  43484. */
  43485. dispose(forceDisposeTextures?: boolean): void;
  43486. /**
  43487. * Get the current class name of the texture useful for serialization or dynamic coding.
  43488. * @returns "PBRClearCoatConfiguration"
  43489. */
  43490. getClassName(): string;
  43491. /**
  43492. * Add fallbacks to the effect fallbacks list.
  43493. * @param defines defines the Base texture to use.
  43494. * @param fallbacks defines the current fallback list.
  43495. * @param currentRank defines the current fallback rank.
  43496. * @returns the new fallback rank.
  43497. */
  43498. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43499. /**
  43500. * Add the required uniforms to the current list.
  43501. * @param uniforms defines the current uniform list.
  43502. */
  43503. static AddUniforms(uniforms: string[]): void;
  43504. /**
  43505. * Add the required samplers to the current list.
  43506. * @param samplers defines the current sampler list.
  43507. */
  43508. static AddSamplers(samplers: string[]): void;
  43509. /**
  43510. * Add the required uniforms to the current buffer.
  43511. * @param uniformBuffer defines the current uniform buffer.
  43512. */
  43513. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43514. /**
  43515. * Makes a duplicate of the current configuration into another one.
  43516. * @param clearCoatConfiguration define the config where to copy the info
  43517. */
  43518. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  43519. /**
  43520. * Serializes this clear coat configuration.
  43521. * @returns - An object with the serialized config.
  43522. */
  43523. serialize(): any;
  43524. /**
  43525. * Parses a Clear Coat Configuration from a serialized object.
  43526. * @param source - Serialized object.
  43527. */
  43528. parse(source: any): void;
  43529. }
  43530. }
  43531. declare module BABYLON {
  43532. /**
  43533. * @hidden
  43534. */
  43535. export interface IMaterialAnisotropicDefines {
  43536. ANISOTROPIC: boolean;
  43537. ANISOTROPIC_TEXTURE: boolean;
  43538. ANISOTROPIC_TEXTUREDIRECTUV: number;
  43539. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  43540. }
  43541. /**
  43542. * Define the code related to the anisotropic parameters of the pbr material.
  43543. */
  43544. export class PBRAnisotropicConfiguration {
  43545. private _isEnabled;
  43546. /**
  43547. * Defines if the anisotropy is enabled in the material.
  43548. */
  43549. isEnabled: boolean;
  43550. /**
  43551. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  43552. */
  43553. intensity: number;
  43554. /**
  43555. * Defines if the effect is along the tangents, bitangents or in between.
  43556. * By default, the effect is "strectching" the highlights along the tangents.
  43557. */
  43558. direction: Vector2;
  43559. private _texture;
  43560. /**
  43561. * Stores the anisotropy values in a texture.
  43562. * rg is direction (like normal from -1 to 1)
  43563. * b is a intensity
  43564. */
  43565. texture: Nullable<BaseTexture>;
  43566. /** @hidden */
  43567. private _internalMarkAllSubMeshesAsTexturesDirty;
  43568. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43569. /**
  43570. * Instantiate a new istance of anisotropy configuration.
  43571. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43572. */
  43573. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43574. /**
  43575. * Specifies that the submesh is ready to be used.
  43576. * @param defines the list of "defines" to update.
  43577. * @param scene defines the scene the material belongs to.
  43578. * @returns - boolean indicating that the submesh is ready or not.
  43579. */
  43580. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  43581. /**
  43582. * Checks to see if a texture is used in the material.
  43583. * @param defines the list of "defines" to update.
  43584. * @param mesh the mesh we are preparing the defines for.
  43585. * @param scene defines the scene the material belongs to.
  43586. */
  43587. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  43588. /**
  43589. * Binds the material data.
  43590. * @param uniformBuffer defines the Uniform buffer to fill in.
  43591. * @param scene defines the scene the material belongs to.
  43592. * @param isFrozen defines wether the material is frozen or not.
  43593. */
  43594. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43595. /**
  43596. * Checks to see if a texture is used in the material.
  43597. * @param texture - Base texture to use.
  43598. * @returns - Boolean specifying if a texture is used in the material.
  43599. */
  43600. hasTexture(texture: BaseTexture): boolean;
  43601. /**
  43602. * Returns an array of the actively used textures.
  43603. * @param activeTextures Array of BaseTextures
  43604. */
  43605. getActiveTextures(activeTextures: BaseTexture[]): void;
  43606. /**
  43607. * Returns the animatable textures.
  43608. * @param animatables Array of animatable textures.
  43609. */
  43610. getAnimatables(animatables: IAnimatable[]): void;
  43611. /**
  43612. * Disposes the resources of the material.
  43613. * @param forceDisposeTextures - Forces the disposal of all textures.
  43614. */
  43615. dispose(forceDisposeTextures?: boolean): void;
  43616. /**
  43617. * Get the current class name of the texture useful for serialization or dynamic coding.
  43618. * @returns "PBRAnisotropicConfiguration"
  43619. */
  43620. getClassName(): string;
  43621. /**
  43622. * Add fallbacks to the effect fallbacks list.
  43623. * @param defines defines the Base texture to use.
  43624. * @param fallbacks defines the current fallback list.
  43625. * @param currentRank defines the current fallback rank.
  43626. * @returns the new fallback rank.
  43627. */
  43628. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43629. /**
  43630. * Add the required uniforms to the current list.
  43631. * @param uniforms defines the current uniform list.
  43632. */
  43633. static AddUniforms(uniforms: string[]): void;
  43634. /**
  43635. * Add the required uniforms to the current buffer.
  43636. * @param uniformBuffer defines the current uniform buffer.
  43637. */
  43638. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43639. /**
  43640. * Add the required samplers to the current list.
  43641. * @param samplers defines the current sampler list.
  43642. */
  43643. static AddSamplers(samplers: string[]): void;
  43644. /**
  43645. * Makes a duplicate of the current configuration into another one.
  43646. * @param anisotropicConfiguration define the config where to copy the info
  43647. */
  43648. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  43649. /**
  43650. * Serializes this anisotropy configuration.
  43651. * @returns - An object with the serialized config.
  43652. */
  43653. serialize(): any;
  43654. /**
  43655. * Parses a anisotropy Configuration from a serialized object.
  43656. * @param source - Serialized object.
  43657. */
  43658. parse(source: any): void;
  43659. }
  43660. }
  43661. declare module BABYLON {
  43662. /**
  43663. * @hidden
  43664. */
  43665. export interface IMaterialBRDFDefines {
  43666. BRDF_V_HEIGHT_CORRELATED: boolean;
  43667. MS_BRDF_ENERGY_CONSERVATION: boolean;
  43668. SPHERICAL_HARMONICS: boolean;
  43669. /** @hidden */ private _areMiscDirty: boolean;
  43670. }
  43671. /**
  43672. * Define the code related to the BRDF parameters of the pbr material.
  43673. */
  43674. export class PBRBRDFConfiguration {
  43675. /**
  43676. * Default value used for the energy conservation.
  43677. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43678. */
  43679. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  43680. /**
  43681. * Default value used for the Smith Visibility Height Correlated mode.
  43682. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  43683. */
  43684. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  43685. /**
  43686. * Default value used for the IBL diffuse part.
  43687. * This can help switching back to the polynomials mode globally which is a tiny bit
  43688. * less GPU intensive at the drawback of a lower quality.
  43689. */
  43690. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  43691. private _useEnergyConservation;
  43692. /**
  43693. * Defines if the material uses energy conservation.
  43694. */
  43695. useEnergyConservation: boolean;
  43696. private _useSmithVisibilityHeightCorrelated;
  43697. /**
  43698. * LEGACY Mode set to false
  43699. * Defines if the material uses height smith correlated visibility term.
  43700. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  43701. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  43702. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  43703. * Not relying on height correlated will also disable energy conservation.
  43704. */
  43705. useSmithVisibilityHeightCorrelated: boolean;
  43706. private _useSphericalHarmonics;
  43707. /**
  43708. * LEGACY Mode set to false
  43709. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  43710. * diffuse part of the IBL.
  43711. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  43712. * to the ground truth.
  43713. */
  43714. useSphericalHarmonics: boolean;
  43715. /** @hidden */
  43716. private _internalMarkAllSubMeshesAsMiscDirty;
  43717. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  43718. /**
  43719. * Instantiate a new istance of clear coat configuration.
  43720. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  43721. */
  43722. constructor(markAllSubMeshesAsMiscDirty: () => void);
  43723. /**
  43724. * Checks to see if a texture is used in the material.
  43725. * @param defines the list of "defines" to update.
  43726. */
  43727. prepareDefines(defines: IMaterialBRDFDefines): void;
  43728. /**
  43729. * Get the current class name of the texture useful for serialization or dynamic coding.
  43730. * @returns "PBRClearCoatConfiguration"
  43731. */
  43732. getClassName(): string;
  43733. /**
  43734. * Makes a duplicate of the current configuration into another one.
  43735. * @param brdfConfiguration define the config where to copy the info
  43736. */
  43737. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  43738. /**
  43739. * Serializes this BRDF configuration.
  43740. * @returns - An object with the serialized config.
  43741. */
  43742. serialize(): any;
  43743. /**
  43744. * Parses a BRDF Configuration from a serialized object.
  43745. * @param source - Serialized object.
  43746. */
  43747. parse(source: any): void;
  43748. }
  43749. }
  43750. declare module BABYLON {
  43751. /**
  43752. * @hidden
  43753. */
  43754. export interface IMaterialSheenDefines {
  43755. SHEEN: boolean;
  43756. SHEEN_TEXTURE: boolean;
  43757. SHEEN_TEXTUREDIRECTUV: number;
  43758. SHEEN_LINKWITHALBEDO: boolean;
  43759. /** @hidden */ private _areTexturesDirty: boolean;
  43760. }
  43761. /**
  43762. * Define the code related to the Sheen parameters of the pbr material.
  43763. */
  43764. export class PBRSheenConfiguration {
  43765. private _isEnabled;
  43766. /**
  43767. * Defines if the material uses sheen.
  43768. */
  43769. isEnabled: boolean;
  43770. private _linkSheenWithAlbedo;
  43771. /**
  43772. * Defines if the sheen is linked to the sheen color.
  43773. */
  43774. linkSheenWithAlbedo: boolean;
  43775. /**
  43776. * Defines the sheen intensity.
  43777. */
  43778. intensity: number;
  43779. /**
  43780. * Defines the sheen color.
  43781. */
  43782. color: Color3;
  43783. private _texture;
  43784. /**
  43785. * Stores the sheen tint values in a texture.
  43786. * rgb is tint
  43787. * a is a intensity
  43788. */
  43789. texture: Nullable<BaseTexture>;
  43790. /** @hidden */
  43791. private _internalMarkAllSubMeshesAsTexturesDirty;
  43792. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  43793. /**
  43794. * Instantiate a new istance of clear coat configuration.
  43795. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  43796. */
  43797. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  43798. /**
  43799. * Specifies that the submesh is ready to be used.
  43800. * @param defines the list of "defines" to update.
  43801. * @param scene defines the scene the material belongs to.
  43802. * @returns - boolean indicating that the submesh is ready or not.
  43803. */
  43804. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  43805. /**
  43806. * Checks to see if a texture is used in the material.
  43807. * @param defines the list of "defines" to update.
  43808. * @param scene defines the scene the material belongs to.
  43809. */
  43810. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  43811. /**
  43812. * Binds the material data.
  43813. * @param uniformBuffer defines the Uniform buffer to fill in.
  43814. * @param scene defines the scene the material belongs to.
  43815. * @param isFrozen defines wether the material is frozen or not.
  43816. */
  43817. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  43818. /**
  43819. * Checks to see if a texture is used in the material.
  43820. * @param texture - Base texture to use.
  43821. * @returns - Boolean specifying if a texture is used in the material.
  43822. */
  43823. hasTexture(texture: BaseTexture): boolean;
  43824. /**
  43825. * Returns an array of the actively used textures.
  43826. * @param activeTextures Array of BaseTextures
  43827. */
  43828. getActiveTextures(activeTextures: BaseTexture[]): void;
  43829. /**
  43830. * Returns the animatable textures.
  43831. * @param animatables Array of animatable textures.
  43832. */
  43833. getAnimatables(animatables: IAnimatable[]): void;
  43834. /**
  43835. * Disposes the resources of the material.
  43836. * @param forceDisposeTextures - Forces the disposal of all textures.
  43837. */
  43838. dispose(forceDisposeTextures?: boolean): void;
  43839. /**
  43840. * Get the current class name of the texture useful for serialization or dynamic coding.
  43841. * @returns "PBRSheenConfiguration"
  43842. */
  43843. getClassName(): string;
  43844. /**
  43845. * Add fallbacks to the effect fallbacks list.
  43846. * @param defines defines the Base texture to use.
  43847. * @param fallbacks defines the current fallback list.
  43848. * @param currentRank defines the current fallback rank.
  43849. * @returns the new fallback rank.
  43850. */
  43851. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  43852. /**
  43853. * Add the required uniforms to the current list.
  43854. * @param uniforms defines the current uniform list.
  43855. */
  43856. static AddUniforms(uniforms: string[]): void;
  43857. /**
  43858. * Add the required uniforms to the current buffer.
  43859. * @param uniformBuffer defines the current uniform buffer.
  43860. */
  43861. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  43862. /**
  43863. * Add the required samplers to the current list.
  43864. * @param samplers defines the current sampler list.
  43865. */
  43866. static AddSamplers(samplers: string[]): void;
  43867. /**
  43868. * Makes a duplicate of the current configuration into another one.
  43869. * @param sheenConfiguration define the config where to copy the info
  43870. */
  43871. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  43872. /**
  43873. * Serializes this BRDF configuration.
  43874. * @returns - An object with the serialized config.
  43875. */
  43876. serialize(): any;
  43877. /**
  43878. * Parses a Sheen Configuration from a serialized object.
  43879. * @param source - Serialized object.
  43880. */
  43881. parse(source: any): void;
  43882. }
  43883. }
  43884. declare module BABYLON {
  43885. /**
  43886. * @hidden
  43887. */
  43888. export interface IMaterialSubSurfaceDefines {
  43889. SUBSURFACE: boolean;
  43890. SS_REFRACTION: boolean;
  43891. SS_TRANSLUCENCY: boolean;
  43892. SS_SCATERRING: boolean;
  43893. SS_THICKNESSANDMASK_TEXTURE: boolean;
  43894. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  43895. SS_REFRACTIONMAP_3D: boolean;
  43896. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  43897. SS_LODINREFRACTIONALPHA: boolean;
  43898. SS_GAMMAREFRACTION: boolean;
  43899. SS_RGBDREFRACTION: boolean;
  43900. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  43901. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  43902. /** @hidden */ private _areTexturesDirty: boolean;
  43903. }
  43904. /**
  43905. * Define the code related to the sub surface parameters of the pbr material.
  43906. */
  43907. export class PBRSubSurfaceConfiguration {
  43908. private _isRefractionEnabled;
  43909. /**
  43910. * Defines if the refraction is enabled in the material.
  43911. */
  43912. isRefractionEnabled: boolean;
  43913. private _isTranslucencyEnabled;
  43914. /**
  43915. * Defines if the translucency is enabled in the material.
  43916. */
  43917. isTranslucencyEnabled: boolean;
  43918. private _isScatteringEnabled;
  43919. /**
  43920. * Defines the refraction intensity of the material.
  43921. * The refraction when enabled replaces the Diffuse part of the material.
  43922. * The intensity helps transitionning between diffuse and refraction.
  43923. */
  43924. refractionIntensity: number;
  43925. /**
  43926. * Defines the translucency intensity of the material.
  43927. * When translucency has been enabled, this defines how much of the "translucency"
  43928. * is addded to the diffuse part of the material.
  43929. */
  43930. translucencyIntensity: number;
  43931. /**
  43932. * Defines the scattering intensity of the material.
  43933. * When scattering has been enabled, this defines how much of the "scattered light"
  43934. * is addded to the diffuse part of the material.
  43935. */
  43936. scatteringIntensity: number;
  43937. private _thicknessTexture;
  43938. /**
  43939. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  43940. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  43941. * 0 would mean minimumThickness
  43942. * 1 would mean maximumThickness
  43943. * The other channels might be use as a mask to vary the different effects intensity.
  43944. */
  43945. thicknessTexture: Nullable<BaseTexture>;
  43946. private _refractionTexture;
  43947. /**
  43948. * Defines the texture to use for refraction.
  43949. */
  43950. refractionTexture: Nullable<BaseTexture>;
  43951. private _indexOfRefraction;
  43952. /**
  43953. * Defines the indice of refraction used in the material.
  43954. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  43955. */
  43956. indexOfRefraction: number;
  43957. private _invertRefractionY;
  43958. /**
  43959. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  43960. */
  43961. invertRefractionY: boolean;
  43962. private _linkRefractionWithTransparency;
  43963. /**
  43964. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  43965. * Materials half opaque for instance using refraction could benefit from this control.
  43966. */
  43967. linkRefractionWithTransparency: boolean;
  43968. /**
  43969. * Defines the minimum thickness stored in the thickness map.
  43970. * If no thickness map is defined, this value will be used to simulate thickness.
  43971. */
  43972. minimumThickness: number;
  43973. /**
  43974. * Defines the maximum thickness stored in the thickness map.
  43975. */
  43976. maximumThickness: number;
  43977. /**
  43978. * Defines the volume tint of the material.
  43979. * This is used for both translucency and scattering.
  43980. */
  43981. tintColor: Color3;
  43982. /**
  43983. * Defines the distance at which the tint color should be found in the media.
  43984. * This is used for refraction only.
  43985. */
  43986. tintColorAtDistance: number;
  43987. /**
  43988. * Defines how far each channel transmit through the media.
  43989. * It is defined as a color to simplify it selection.
  43990. */
  43991. diffusionDistance: Color3;
  43992. private _useMaskFromThicknessTexture;
  43993. /**
  43994. * Stores the intensity of the different subsurface effects in the thickness texture.
  43995. * * the green channel is the translucency intensity.
  43996. * * the blue channel is the scattering intensity.
  43997. * * the alpha channel is the refraction intensity.
  43998. */
  43999. useMaskFromThicknessTexture: boolean;
  44000. /** @hidden */
  44001. private _internalMarkAllSubMeshesAsTexturesDirty;
  44002. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44003. /**
  44004. * Instantiate a new istance of sub surface configuration.
  44005. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44006. */
  44007. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44008. /**
  44009. * Gets wehter the submesh is ready to be used or not.
  44010. * @param defines the list of "defines" to update.
  44011. * @param scene defines the scene the material belongs to.
  44012. * @returns - boolean indicating that the submesh is ready or not.
  44013. */
  44014. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  44015. /**
  44016. * Checks to see if a texture is used in the material.
  44017. * @param defines the list of "defines" to update.
  44018. * @param scene defines the scene to the material belongs to.
  44019. */
  44020. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  44021. /**
  44022. * Binds the material data.
  44023. * @param uniformBuffer defines the Uniform buffer to fill in.
  44024. * @param scene defines the scene the material belongs to.
  44025. * @param engine defines the engine the material belongs to.
  44026. * @param isFrozen defines wether the material is frozen or not.
  44027. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  44028. */
  44029. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  44030. /**
  44031. * Unbinds the material from the mesh.
  44032. * @param activeEffect defines the effect that should be unbound from.
  44033. * @returns true if unbound, otherwise false
  44034. */
  44035. unbind(activeEffect: Effect): boolean;
  44036. /**
  44037. * Returns the texture used for refraction or null if none is used.
  44038. * @param scene defines the scene the material belongs to.
  44039. * @returns - Refraction texture if present. If no refraction texture and refraction
  44040. * is linked with transparency, returns environment texture. Otherwise, returns null.
  44041. */
  44042. private _getRefractionTexture;
  44043. /**
  44044. * Returns true if alpha blending should be disabled.
  44045. */
  44046. readonly disableAlphaBlending: boolean;
  44047. /**
  44048. * Fills the list of render target textures.
  44049. * @param renderTargets the list of render targets to update
  44050. */
  44051. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  44052. /**
  44053. * Checks to see if a texture is used in the material.
  44054. * @param texture - Base texture to use.
  44055. * @returns - Boolean specifying if a texture is used in the material.
  44056. */
  44057. hasTexture(texture: BaseTexture): boolean;
  44058. /**
  44059. * Gets a boolean indicating that current material needs to register RTT
  44060. * @returns true if this uses a render target otherwise false.
  44061. */
  44062. hasRenderTargetTextures(): boolean;
  44063. /**
  44064. * Returns an array of the actively used textures.
  44065. * @param activeTextures Array of BaseTextures
  44066. */
  44067. getActiveTextures(activeTextures: BaseTexture[]): void;
  44068. /**
  44069. * Returns the animatable textures.
  44070. * @param animatables Array of animatable textures.
  44071. */
  44072. getAnimatables(animatables: IAnimatable[]): void;
  44073. /**
  44074. * Disposes the resources of the material.
  44075. * @param forceDisposeTextures - Forces the disposal of all textures.
  44076. */
  44077. dispose(forceDisposeTextures?: boolean): void;
  44078. /**
  44079. * Get the current class name of the texture useful for serialization or dynamic coding.
  44080. * @returns "PBRSubSurfaceConfiguration"
  44081. */
  44082. getClassName(): string;
  44083. /**
  44084. * Add fallbacks to the effect fallbacks list.
  44085. * @param defines defines the Base texture to use.
  44086. * @param fallbacks defines the current fallback list.
  44087. * @param currentRank defines the current fallback rank.
  44088. * @returns the new fallback rank.
  44089. */
  44090. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44091. /**
  44092. * Add the required uniforms to the current list.
  44093. * @param uniforms defines the current uniform list.
  44094. */
  44095. static AddUniforms(uniforms: string[]): void;
  44096. /**
  44097. * Add the required samplers to the current list.
  44098. * @param samplers defines the current sampler list.
  44099. */
  44100. static AddSamplers(samplers: string[]): void;
  44101. /**
  44102. * Add the required uniforms to the current buffer.
  44103. * @param uniformBuffer defines the current uniform buffer.
  44104. */
  44105. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44106. /**
  44107. * Makes a duplicate of the current configuration into another one.
  44108. * @param configuration define the config where to copy the info
  44109. */
  44110. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  44111. /**
  44112. * Serializes this Sub Surface configuration.
  44113. * @returns - An object with the serialized config.
  44114. */
  44115. serialize(): any;
  44116. /**
  44117. * Parses a Sub Surface Configuration from a serialized object.
  44118. * @param source - Serialized object.
  44119. */
  44120. parse(source: any): void;
  44121. }
  44122. }
  44123. declare module BABYLON {
  44124. /** @hidden */
  44125. export var pbrFragmentDeclaration: {
  44126. name: string;
  44127. shader: string;
  44128. };
  44129. }
  44130. declare module BABYLON {
  44131. /** @hidden */
  44132. export var pbrUboDeclaration: {
  44133. name: string;
  44134. shader: string;
  44135. };
  44136. }
  44137. declare module BABYLON {
  44138. /** @hidden */
  44139. export var pbrFragmentExtraDeclaration: {
  44140. name: string;
  44141. shader: string;
  44142. };
  44143. }
  44144. declare module BABYLON {
  44145. /** @hidden */
  44146. export var pbrFragmentSamplersDeclaration: {
  44147. name: string;
  44148. shader: string;
  44149. };
  44150. }
  44151. declare module BABYLON {
  44152. /** @hidden */
  44153. export var pbrHelperFunctions: {
  44154. name: string;
  44155. shader: string;
  44156. };
  44157. }
  44158. declare module BABYLON {
  44159. /** @hidden */
  44160. export var harmonicsFunctions: {
  44161. name: string;
  44162. shader: string;
  44163. };
  44164. }
  44165. declare module BABYLON {
  44166. /** @hidden */
  44167. export var pbrDirectLightingSetupFunctions: {
  44168. name: string;
  44169. shader: string;
  44170. };
  44171. }
  44172. declare module BABYLON {
  44173. /** @hidden */
  44174. export var pbrDirectLightingFalloffFunctions: {
  44175. name: string;
  44176. shader: string;
  44177. };
  44178. }
  44179. declare module BABYLON {
  44180. /** @hidden */
  44181. export var pbrBRDFFunctions: {
  44182. name: string;
  44183. shader: string;
  44184. };
  44185. }
  44186. declare module BABYLON {
  44187. /** @hidden */
  44188. export var pbrDirectLightingFunctions: {
  44189. name: string;
  44190. shader: string;
  44191. };
  44192. }
  44193. declare module BABYLON {
  44194. /** @hidden */
  44195. export var pbrIBLFunctions: {
  44196. name: string;
  44197. shader: string;
  44198. };
  44199. }
  44200. declare module BABYLON {
  44201. /** @hidden */
  44202. export var pbrDebug: {
  44203. name: string;
  44204. shader: string;
  44205. };
  44206. }
  44207. declare module BABYLON {
  44208. /** @hidden */
  44209. export var pbrPixelShader: {
  44210. name: string;
  44211. shader: string;
  44212. };
  44213. }
  44214. declare module BABYLON {
  44215. /** @hidden */
  44216. export var pbrVertexDeclaration: {
  44217. name: string;
  44218. shader: string;
  44219. };
  44220. }
  44221. declare module BABYLON {
  44222. /** @hidden */
  44223. export var pbrVertexShader: {
  44224. name: string;
  44225. shader: string;
  44226. };
  44227. }
  44228. declare module BABYLON {
  44229. /**
  44230. * Manages the defines for the PBR Material.
  44231. * @hidden
  44232. */
  44233. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  44234. PBR: boolean;
  44235. MAINUV1: boolean;
  44236. MAINUV2: boolean;
  44237. UV1: boolean;
  44238. UV2: boolean;
  44239. ALBEDO: boolean;
  44240. ALBEDODIRECTUV: number;
  44241. VERTEXCOLOR: boolean;
  44242. AMBIENT: boolean;
  44243. AMBIENTDIRECTUV: number;
  44244. AMBIENTINGRAYSCALE: boolean;
  44245. OPACITY: boolean;
  44246. VERTEXALPHA: boolean;
  44247. OPACITYDIRECTUV: number;
  44248. OPACITYRGB: boolean;
  44249. ALPHATEST: boolean;
  44250. DEPTHPREPASS: boolean;
  44251. ALPHABLEND: boolean;
  44252. ALPHAFROMALBEDO: boolean;
  44253. ALPHATESTVALUE: string;
  44254. SPECULAROVERALPHA: boolean;
  44255. RADIANCEOVERALPHA: boolean;
  44256. ALPHAFRESNEL: boolean;
  44257. LINEARALPHAFRESNEL: boolean;
  44258. PREMULTIPLYALPHA: boolean;
  44259. EMISSIVE: boolean;
  44260. EMISSIVEDIRECTUV: number;
  44261. REFLECTIVITY: boolean;
  44262. REFLECTIVITYDIRECTUV: number;
  44263. SPECULARTERM: boolean;
  44264. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  44265. MICROSURFACEAUTOMATIC: boolean;
  44266. LODBASEDMICROSFURACE: boolean;
  44267. MICROSURFACEMAP: boolean;
  44268. MICROSURFACEMAPDIRECTUV: number;
  44269. METALLICWORKFLOW: boolean;
  44270. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  44271. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  44272. METALLNESSSTOREINMETALMAPBLUE: boolean;
  44273. AOSTOREINMETALMAPRED: boolean;
  44274. ENVIRONMENTBRDF: boolean;
  44275. ENVIRONMENTBRDF_RGBD: boolean;
  44276. NORMAL: boolean;
  44277. TANGENT: boolean;
  44278. BUMP: boolean;
  44279. BUMPDIRECTUV: number;
  44280. OBJECTSPACE_NORMALMAP: boolean;
  44281. PARALLAX: boolean;
  44282. PARALLAXOCCLUSION: boolean;
  44283. NORMALXYSCALE: boolean;
  44284. LIGHTMAP: boolean;
  44285. LIGHTMAPDIRECTUV: number;
  44286. USELIGHTMAPASSHADOWMAP: boolean;
  44287. GAMMALIGHTMAP: boolean;
  44288. REFLECTION: boolean;
  44289. REFLECTIONMAP_3D: boolean;
  44290. REFLECTIONMAP_SPHERICAL: boolean;
  44291. REFLECTIONMAP_PLANAR: boolean;
  44292. REFLECTIONMAP_CUBIC: boolean;
  44293. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  44294. REFLECTIONMAP_PROJECTION: boolean;
  44295. REFLECTIONMAP_SKYBOX: boolean;
  44296. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  44297. REFLECTIONMAP_EXPLICIT: boolean;
  44298. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  44299. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  44300. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  44301. INVERTCUBICMAP: boolean;
  44302. USESPHERICALFROMREFLECTIONMAP: boolean;
  44303. SPHERICAL_HARMONICS: boolean;
  44304. USESPHERICALINVERTEX: boolean;
  44305. REFLECTIONMAP_OPPOSITEZ: boolean;
  44306. LODINREFLECTIONALPHA: boolean;
  44307. GAMMAREFLECTION: boolean;
  44308. RGBDREFLECTION: boolean;
  44309. RADIANCEOCCLUSION: boolean;
  44310. HORIZONOCCLUSION: boolean;
  44311. INSTANCES: boolean;
  44312. NUM_BONE_INFLUENCERS: number;
  44313. BonesPerMesh: number;
  44314. BONETEXTURE: boolean;
  44315. NONUNIFORMSCALING: boolean;
  44316. MORPHTARGETS: boolean;
  44317. MORPHTARGETS_NORMAL: boolean;
  44318. MORPHTARGETS_TANGENT: boolean;
  44319. NUM_MORPH_INFLUENCERS: number;
  44320. IMAGEPROCESSING: boolean;
  44321. VIGNETTE: boolean;
  44322. VIGNETTEBLENDMODEMULTIPLY: boolean;
  44323. VIGNETTEBLENDMODEOPAQUE: boolean;
  44324. TONEMAPPING: boolean;
  44325. TONEMAPPING_ACES: boolean;
  44326. CONTRAST: boolean;
  44327. COLORCURVES: boolean;
  44328. COLORGRADING: boolean;
  44329. COLORGRADING3D: boolean;
  44330. SAMPLER3DGREENDEPTH: boolean;
  44331. SAMPLER3DBGRMAP: boolean;
  44332. IMAGEPROCESSINGPOSTPROCESS: boolean;
  44333. EXPOSURE: boolean;
  44334. MULTIVIEW: boolean;
  44335. USEPHYSICALLIGHTFALLOFF: boolean;
  44336. USEGLTFLIGHTFALLOFF: boolean;
  44337. TWOSIDEDLIGHTING: boolean;
  44338. SHADOWFLOAT: boolean;
  44339. CLIPPLANE: boolean;
  44340. CLIPPLANE2: boolean;
  44341. CLIPPLANE3: boolean;
  44342. CLIPPLANE4: boolean;
  44343. POINTSIZE: boolean;
  44344. FOG: boolean;
  44345. LOGARITHMICDEPTH: boolean;
  44346. FORCENORMALFORWARD: boolean;
  44347. SPECULARAA: boolean;
  44348. CLEARCOAT: boolean;
  44349. CLEARCOAT_DEFAULTIOR: boolean;
  44350. CLEARCOAT_TEXTURE: boolean;
  44351. CLEARCOAT_TEXTUREDIRECTUV: number;
  44352. CLEARCOAT_BUMP: boolean;
  44353. CLEARCOAT_BUMPDIRECTUV: number;
  44354. CLEARCOAT_TINT: boolean;
  44355. CLEARCOAT_TINT_TEXTURE: boolean;
  44356. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44357. ANISOTROPIC: boolean;
  44358. ANISOTROPIC_TEXTURE: boolean;
  44359. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44360. BRDF_V_HEIGHT_CORRELATED: boolean;
  44361. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44362. SHEEN: boolean;
  44363. SHEEN_TEXTURE: boolean;
  44364. SHEEN_TEXTUREDIRECTUV: number;
  44365. SHEEN_LINKWITHALBEDO: boolean;
  44366. SUBSURFACE: boolean;
  44367. SS_REFRACTION: boolean;
  44368. SS_TRANSLUCENCY: boolean;
  44369. SS_SCATERRING: boolean;
  44370. SS_THICKNESSANDMASK_TEXTURE: boolean;
  44371. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  44372. SS_REFRACTIONMAP_3D: boolean;
  44373. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  44374. SS_LODINREFRACTIONALPHA: boolean;
  44375. SS_GAMMAREFRACTION: boolean;
  44376. SS_RGBDREFRACTION: boolean;
  44377. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  44378. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  44379. UNLIT: boolean;
  44380. DEBUGMODE: number;
  44381. /**
  44382. * Initializes the PBR Material defines.
  44383. */
  44384. constructor();
  44385. /**
  44386. * Resets the PBR Material defines.
  44387. */
  44388. reset(): void;
  44389. }
  44390. /**
  44391. * The Physically based material base class of BJS.
  44392. *
  44393. * This offers the main features of a standard PBR material.
  44394. * For more information, please refer to the documentation :
  44395. * https://doc.babylonjs.com/how_to/physically_based_rendering
  44396. */
  44397. export abstract class PBRBaseMaterial extends PushMaterial {
  44398. /**
  44399. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44400. */
  44401. static readonly PBRMATERIAL_OPAQUE: number;
  44402. /**
  44403. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44404. */
  44405. static readonly PBRMATERIAL_ALPHATEST: number;
  44406. /**
  44407. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44408. */
  44409. static readonly PBRMATERIAL_ALPHABLEND: number;
  44410. /**
  44411. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44412. * They are also discarded below the alpha cutoff threshold to improve performances.
  44413. */
  44414. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44415. /**
  44416. * Defines the default value of how much AO map is occluding the analytical lights
  44417. * (point spot...).
  44418. */
  44419. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44420. /**
  44421. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  44422. */
  44423. static readonly LIGHTFALLOFF_PHYSICAL: number;
  44424. /**
  44425. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  44426. * to enhance interoperability with other engines.
  44427. */
  44428. static readonly LIGHTFALLOFF_GLTF: number;
  44429. /**
  44430. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  44431. * to enhance interoperability with other materials.
  44432. */
  44433. static readonly LIGHTFALLOFF_STANDARD: number;
  44434. /**
  44435. * Intensity of the direct lights e.g. the four lights available in your scene.
  44436. * This impacts both the direct diffuse and specular highlights.
  44437. */
  44438. protected _directIntensity: number;
  44439. /**
  44440. * Intensity of the emissive part of the material.
  44441. * This helps controlling the emissive effect without modifying the emissive color.
  44442. */
  44443. protected _emissiveIntensity: number;
  44444. /**
  44445. * Intensity of the environment e.g. how much the environment will light the object
  44446. * either through harmonics for rough material or through the refelction for shiny ones.
  44447. */
  44448. protected _environmentIntensity: number;
  44449. /**
  44450. * This is a special control allowing the reduction of the specular highlights coming from the
  44451. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44452. */
  44453. protected _specularIntensity: number;
  44454. /**
  44455. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  44456. */
  44457. private _lightingInfos;
  44458. /**
  44459. * Debug Control allowing disabling the bump map on this material.
  44460. */
  44461. protected _disableBumpMap: boolean;
  44462. /**
  44463. * AKA Diffuse Texture in standard nomenclature.
  44464. */
  44465. protected _albedoTexture: Nullable<BaseTexture>;
  44466. /**
  44467. * AKA Occlusion Texture in other nomenclature.
  44468. */
  44469. protected _ambientTexture: Nullable<BaseTexture>;
  44470. /**
  44471. * AKA Occlusion Texture Intensity in other nomenclature.
  44472. */
  44473. protected _ambientTextureStrength: number;
  44474. /**
  44475. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44476. * 1 means it completely occludes it
  44477. * 0 mean it has no impact
  44478. */
  44479. protected _ambientTextureImpactOnAnalyticalLights: number;
  44480. /**
  44481. * Stores the alpha values in a texture.
  44482. */
  44483. protected _opacityTexture: Nullable<BaseTexture>;
  44484. /**
  44485. * Stores the reflection values in a texture.
  44486. */
  44487. protected _reflectionTexture: Nullable<BaseTexture>;
  44488. /**
  44489. * Stores the emissive values in a texture.
  44490. */
  44491. protected _emissiveTexture: Nullable<BaseTexture>;
  44492. /**
  44493. * AKA Specular texture in other nomenclature.
  44494. */
  44495. protected _reflectivityTexture: Nullable<BaseTexture>;
  44496. /**
  44497. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44498. */
  44499. protected _metallicTexture: Nullable<BaseTexture>;
  44500. /**
  44501. * Specifies the metallic scalar of the metallic/roughness workflow.
  44502. * Can also be used to scale the metalness values of the metallic texture.
  44503. */
  44504. protected _metallic: Nullable<number>;
  44505. /**
  44506. * Specifies the roughness scalar of the metallic/roughness workflow.
  44507. * Can also be used to scale the roughness values of the metallic texture.
  44508. */
  44509. protected _roughness: Nullable<number>;
  44510. /**
  44511. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44512. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44513. */
  44514. protected _microSurfaceTexture: Nullable<BaseTexture>;
  44515. /**
  44516. * Stores surface normal data used to displace a mesh in a texture.
  44517. */
  44518. protected _bumpTexture: Nullable<BaseTexture>;
  44519. /**
  44520. * Stores the pre-calculated light information of a mesh in a texture.
  44521. */
  44522. protected _lightmapTexture: Nullable<BaseTexture>;
  44523. /**
  44524. * The color of a material in ambient lighting.
  44525. */
  44526. protected _ambientColor: Color3;
  44527. /**
  44528. * AKA Diffuse Color in other nomenclature.
  44529. */
  44530. protected _albedoColor: Color3;
  44531. /**
  44532. * AKA Specular Color in other nomenclature.
  44533. */
  44534. protected _reflectivityColor: Color3;
  44535. /**
  44536. * The color applied when light is reflected from a material.
  44537. */
  44538. protected _reflectionColor: Color3;
  44539. /**
  44540. * The color applied when light is emitted from a material.
  44541. */
  44542. protected _emissiveColor: Color3;
  44543. /**
  44544. * AKA Glossiness in other nomenclature.
  44545. */
  44546. protected _microSurface: number;
  44547. /**
  44548. * Specifies that the material will use the light map as a show map.
  44549. */
  44550. protected _useLightmapAsShadowmap: boolean;
  44551. /**
  44552. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  44553. * makes the reflect vector face the model (under horizon).
  44554. */
  44555. protected _useHorizonOcclusion: boolean;
  44556. /**
  44557. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  44558. * too much the area relying on ambient texture to define their ambient occlusion.
  44559. */
  44560. protected _useRadianceOcclusion: boolean;
  44561. /**
  44562. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  44563. */
  44564. protected _useAlphaFromAlbedoTexture: boolean;
  44565. /**
  44566. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  44567. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  44568. */
  44569. protected _useSpecularOverAlpha: boolean;
  44570. /**
  44571. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  44572. */
  44573. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  44574. /**
  44575. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  44576. */
  44577. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  44578. /**
  44579. * Specifies if the metallic texture contains the roughness information in its green channel.
  44580. */
  44581. protected _useRoughnessFromMetallicTextureGreen: boolean;
  44582. /**
  44583. * Specifies if the metallic texture contains the metallness information in its blue channel.
  44584. */
  44585. protected _useMetallnessFromMetallicTextureBlue: boolean;
  44586. /**
  44587. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  44588. */
  44589. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  44590. /**
  44591. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  44592. */
  44593. protected _useAmbientInGrayScale: boolean;
  44594. /**
  44595. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  44596. * The material will try to infer what glossiness each pixel should be.
  44597. */
  44598. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  44599. /**
  44600. * Defines the falloff type used in this material.
  44601. * It by default is Physical.
  44602. */
  44603. protected _lightFalloff: number;
  44604. /**
  44605. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  44606. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  44607. */
  44608. protected _useRadianceOverAlpha: boolean;
  44609. /**
  44610. * Allows using an object space normal map (instead of tangent space).
  44611. */
  44612. protected _useObjectSpaceNormalMap: boolean;
  44613. /**
  44614. * Allows using the bump map in parallax mode.
  44615. */
  44616. protected _useParallax: boolean;
  44617. /**
  44618. * Allows using the bump map in parallax occlusion mode.
  44619. */
  44620. protected _useParallaxOcclusion: boolean;
  44621. /**
  44622. * Controls the scale bias of the parallax mode.
  44623. */
  44624. protected _parallaxScaleBias: number;
  44625. /**
  44626. * If sets to true, disables all the lights affecting the material.
  44627. */
  44628. protected _disableLighting: boolean;
  44629. /**
  44630. * Number of Simultaneous lights allowed on the material.
  44631. */
  44632. protected _maxSimultaneousLights: number;
  44633. /**
  44634. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44635. */
  44636. protected _invertNormalMapX: boolean;
  44637. /**
  44638. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44639. */
  44640. protected _invertNormalMapY: boolean;
  44641. /**
  44642. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  44643. */
  44644. protected _twoSidedLighting: boolean;
  44645. /**
  44646. * Defines the alpha limits in alpha test mode.
  44647. */
  44648. protected _alphaCutOff: number;
  44649. /**
  44650. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  44651. */
  44652. protected _forceAlphaTest: boolean;
  44653. /**
  44654. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44655. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  44656. */
  44657. protected _useAlphaFresnel: boolean;
  44658. /**
  44659. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  44660. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  44661. */
  44662. protected _useLinearAlphaFresnel: boolean;
  44663. /**
  44664. * The transparency mode of the material.
  44665. */
  44666. protected _transparencyMode: Nullable<number>;
  44667. /**
  44668. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  44669. * from cos thetav and roughness:
  44670. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  44671. */
  44672. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  44673. /**
  44674. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  44675. */
  44676. protected _forceIrradianceInFragment: boolean;
  44677. /**
  44678. * Force normal to face away from face.
  44679. */
  44680. protected _forceNormalForward: boolean;
  44681. /**
  44682. * Enables specular anti aliasing in the PBR shader.
  44683. * It will both interacts on the Geometry for analytical and IBL lighting.
  44684. * It also prefilter the roughness map based on the bump values.
  44685. */
  44686. protected _enableSpecularAntiAliasing: boolean;
  44687. /**
  44688. * Default configuration related to image processing available in the PBR Material.
  44689. */
  44690. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44691. /**
  44692. * Keep track of the image processing observer to allow dispose and replace.
  44693. */
  44694. private _imageProcessingObserver;
  44695. /**
  44696. * Attaches a new image processing configuration to the PBR Material.
  44697. * @param configuration
  44698. */
  44699. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44700. /**
  44701. * Stores the available render targets.
  44702. */
  44703. private _renderTargets;
  44704. /**
  44705. * Sets the global ambient color for the material used in lighting calculations.
  44706. */
  44707. private _globalAmbientColor;
  44708. /**
  44709. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  44710. */
  44711. private _useLogarithmicDepth;
  44712. /**
  44713. * If set to true, no lighting calculations will be applied.
  44714. */
  44715. private _unlit;
  44716. private _debugMode;
  44717. /**
  44718. * @hidden
  44719. * This is reserved for the inspector.
  44720. * Defines the material debug mode.
  44721. * It helps seeing only some components of the material while troubleshooting.
  44722. */
  44723. debugMode: number;
  44724. /**
  44725. * @hidden
  44726. * This is reserved for the inspector.
  44727. * Specify from where on screen the debug mode should start.
  44728. * The value goes from -1 (full screen) to 1 (not visible)
  44729. * It helps with side by side comparison against the final render
  44730. * This defaults to -1
  44731. */
  44732. private debugLimit;
  44733. /**
  44734. * @hidden
  44735. * This is reserved for the inspector.
  44736. * As the default viewing range might not be enough (if the ambient is really small for instance)
  44737. * You can use the factor to better multiply the final value.
  44738. */
  44739. private debugFactor;
  44740. /**
  44741. * Defines the clear coat layer parameters for the material.
  44742. */
  44743. readonly clearCoat: PBRClearCoatConfiguration;
  44744. /**
  44745. * Defines the anisotropic parameters for the material.
  44746. */
  44747. readonly anisotropy: PBRAnisotropicConfiguration;
  44748. /**
  44749. * Defines the BRDF parameters for the material.
  44750. */
  44751. readonly brdf: PBRBRDFConfiguration;
  44752. /**
  44753. * Defines the Sheen parameters for the material.
  44754. */
  44755. readonly sheen: PBRSheenConfiguration;
  44756. /**
  44757. * Defines the SubSurface parameters for the material.
  44758. */
  44759. readonly subSurface: PBRSubSurfaceConfiguration;
  44760. /**
  44761. * Custom callback helping to override the default shader used in the material.
  44762. */
  44763. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  44764. /**
  44765. * Instantiates a new PBRMaterial instance.
  44766. *
  44767. * @param name The material name
  44768. * @param scene The scene the material will be use in.
  44769. */
  44770. constructor(name: string, scene: Scene);
  44771. /**
  44772. * Gets a boolean indicating that current material needs to register RTT
  44773. */
  44774. readonly hasRenderTargetTextures: boolean;
  44775. /**
  44776. * Gets the name of the material class.
  44777. */
  44778. getClassName(): string;
  44779. /**
  44780. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44781. */
  44782. /**
  44783. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  44784. */
  44785. useLogarithmicDepth: boolean;
  44786. /**
  44787. * Gets the current transparency mode.
  44788. */
  44789. /**
  44790. * Sets the transparency mode of the material.
  44791. *
  44792. * | Value | Type | Description |
  44793. * | ----- | ----------------------------------- | ----------- |
  44794. * | 0 | OPAQUE | |
  44795. * | 1 | ALPHATEST | |
  44796. * | 2 | ALPHABLEND | |
  44797. * | 3 | ALPHATESTANDBLEND | |
  44798. *
  44799. */
  44800. transparencyMode: Nullable<number>;
  44801. /**
  44802. * Returns true if alpha blending should be disabled.
  44803. */
  44804. private readonly _disableAlphaBlending;
  44805. /**
  44806. * Specifies whether or not this material should be rendered in alpha blend mode.
  44807. */
  44808. needAlphaBlending(): boolean;
  44809. /**
  44810. * Specifies if the mesh will require alpha blending.
  44811. * @param mesh - BJS mesh.
  44812. */
  44813. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  44814. /**
  44815. * Specifies whether or not this material should be rendered in alpha test mode.
  44816. */
  44817. needAlphaTesting(): boolean;
  44818. /**
  44819. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  44820. */
  44821. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  44822. /**
  44823. * Gets the texture used for the alpha test.
  44824. */
  44825. getAlphaTestTexture(): Nullable<BaseTexture>;
  44826. /**
  44827. * Specifies that the submesh is ready to be used.
  44828. * @param mesh - BJS mesh.
  44829. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  44830. * @param useInstances - Specifies that instances should be used.
  44831. * @returns - boolean indicating that the submesh is ready or not.
  44832. */
  44833. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44834. /**
  44835. * Specifies if the material uses metallic roughness workflow.
  44836. * @returns boolean specifiying if the material uses metallic roughness workflow.
  44837. */
  44838. isMetallicWorkflow(): boolean;
  44839. private _prepareEffect;
  44840. private _prepareDefines;
  44841. /**
  44842. * Force shader compilation
  44843. */
  44844. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  44845. clipPlane: boolean;
  44846. }>): void;
  44847. /**
  44848. * Initializes the uniform buffer layout for the shader.
  44849. */
  44850. buildUniformLayout(): void;
  44851. /**
  44852. * Unbinds the material from the mesh
  44853. */
  44854. unbind(): void;
  44855. /**
  44856. * Binds the submesh data.
  44857. * @param world - The world matrix.
  44858. * @param mesh - The BJS mesh.
  44859. * @param subMesh - A submesh of the BJS mesh.
  44860. */
  44861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44862. /**
  44863. * Returns the animatable textures.
  44864. * @returns - Array of animatable textures.
  44865. */
  44866. getAnimatables(): IAnimatable[];
  44867. /**
  44868. * Returns the texture used for reflections.
  44869. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  44870. */
  44871. private _getReflectionTexture;
  44872. /**
  44873. * Returns an array of the actively used textures.
  44874. * @returns - Array of BaseTextures
  44875. */
  44876. getActiveTextures(): BaseTexture[];
  44877. /**
  44878. * Checks to see if a texture is used in the material.
  44879. * @param texture - Base texture to use.
  44880. * @returns - Boolean specifying if a texture is used in the material.
  44881. */
  44882. hasTexture(texture: BaseTexture): boolean;
  44883. /**
  44884. * Disposes the resources of the material.
  44885. * @param forceDisposeEffect - Forces the disposal of effects.
  44886. * @param forceDisposeTextures - Forces the disposal of all textures.
  44887. */
  44888. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44889. }
  44890. }
  44891. declare module BABYLON {
  44892. /**
  44893. * The Physically based material of BJS.
  44894. *
  44895. * This offers the main features of a standard PBR material.
  44896. * For more information, please refer to the documentation :
  44897. * https://doc.babylonjs.com/how_to/physically_based_rendering
  44898. */
  44899. export class PBRMaterial extends PBRBaseMaterial {
  44900. /**
  44901. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  44902. */
  44903. static readonly PBRMATERIAL_OPAQUE: number;
  44904. /**
  44905. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  44906. */
  44907. static readonly PBRMATERIAL_ALPHATEST: number;
  44908. /**
  44909. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44910. */
  44911. static readonly PBRMATERIAL_ALPHABLEND: number;
  44912. /**
  44913. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  44914. * They are also discarded below the alpha cutoff threshold to improve performances.
  44915. */
  44916. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  44917. /**
  44918. * Defines the default value of how much AO map is occluding the analytical lights
  44919. * (point spot...).
  44920. */
  44921. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  44922. /**
  44923. * Intensity of the direct lights e.g. the four lights available in your scene.
  44924. * This impacts both the direct diffuse and specular highlights.
  44925. */
  44926. directIntensity: number;
  44927. /**
  44928. * Intensity of the emissive part of the material.
  44929. * This helps controlling the emissive effect without modifying the emissive color.
  44930. */
  44931. emissiveIntensity: number;
  44932. /**
  44933. * Intensity of the environment e.g. how much the environment will light the object
  44934. * either through harmonics for rough material or through the refelction for shiny ones.
  44935. */
  44936. environmentIntensity: number;
  44937. /**
  44938. * This is a special control allowing the reduction of the specular highlights coming from the
  44939. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  44940. */
  44941. specularIntensity: number;
  44942. /**
  44943. * Debug Control allowing disabling the bump map on this material.
  44944. */
  44945. disableBumpMap: boolean;
  44946. /**
  44947. * AKA Diffuse Texture in standard nomenclature.
  44948. */
  44949. albedoTexture: BaseTexture;
  44950. /**
  44951. * AKA Occlusion Texture in other nomenclature.
  44952. */
  44953. ambientTexture: BaseTexture;
  44954. /**
  44955. * AKA Occlusion Texture Intensity in other nomenclature.
  44956. */
  44957. ambientTextureStrength: number;
  44958. /**
  44959. * Defines how much the AO map is occluding the analytical lights (point spot...).
  44960. * 1 means it completely occludes it
  44961. * 0 mean it has no impact
  44962. */
  44963. ambientTextureImpactOnAnalyticalLights: number;
  44964. /**
  44965. * Stores the alpha values in a texture.
  44966. */
  44967. opacityTexture: BaseTexture;
  44968. /**
  44969. * Stores the reflection values in a texture.
  44970. */
  44971. reflectionTexture: Nullable<BaseTexture>;
  44972. /**
  44973. * Stores the emissive values in a texture.
  44974. */
  44975. emissiveTexture: BaseTexture;
  44976. /**
  44977. * AKA Specular texture in other nomenclature.
  44978. */
  44979. reflectivityTexture: BaseTexture;
  44980. /**
  44981. * Used to switch from specular/glossiness to metallic/roughness workflow.
  44982. */
  44983. metallicTexture: BaseTexture;
  44984. /**
  44985. * Specifies the metallic scalar of the metallic/roughness workflow.
  44986. * Can also be used to scale the metalness values of the metallic texture.
  44987. */
  44988. metallic: Nullable<number>;
  44989. /**
  44990. * Specifies the roughness scalar of the metallic/roughness workflow.
  44991. * Can also be used to scale the roughness values of the metallic texture.
  44992. */
  44993. roughness: Nullable<number>;
  44994. /**
  44995. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  44996. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  44997. */
  44998. microSurfaceTexture: BaseTexture;
  44999. /**
  45000. * Stores surface normal data used to displace a mesh in a texture.
  45001. */
  45002. bumpTexture: BaseTexture;
  45003. /**
  45004. * Stores the pre-calculated light information of a mesh in a texture.
  45005. */
  45006. lightmapTexture: BaseTexture;
  45007. /**
  45008. * Stores the refracted light information in a texture.
  45009. */
  45010. refractionTexture: Nullable<BaseTexture>;
  45011. /**
  45012. * The color of a material in ambient lighting.
  45013. */
  45014. ambientColor: Color3;
  45015. /**
  45016. * AKA Diffuse Color in other nomenclature.
  45017. */
  45018. albedoColor: Color3;
  45019. /**
  45020. * AKA Specular Color in other nomenclature.
  45021. */
  45022. reflectivityColor: Color3;
  45023. /**
  45024. * The color reflected from the material.
  45025. */
  45026. reflectionColor: Color3;
  45027. /**
  45028. * The color emitted from the material.
  45029. */
  45030. emissiveColor: Color3;
  45031. /**
  45032. * AKA Glossiness in other nomenclature.
  45033. */
  45034. microSurface: number;
  45035. /**
  45036. * source material index of refraction (IOR)' / 'destination material IOR.
  45037. */
  45038. indexOfRefraction: number;
  45039. /**
  45040. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45041. */
  45042. invertRefractionY: boolean;
  45043. /**
  45044. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45045. * Materials half opaque for instance using refraction could benefit from this control.
  45046. */
  45047. linkRefractionWithTransparency: boolean;
  45048. /**
  45049. * If true, the light map contains occlusion information instead of lighting info.
  45050. */
  45051. useLightmapAsShadowmap: boolean;
  45052. /**
  45053. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45054. */
  45055. useAlphaFromAlbedoTexture: boolean;
  45056. /**
  45057. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45058. */
  45059. forceAlphaTest: boolean;
  45060. /**
  45061. * Defines the alpha limits in alpha test mode.
  45062. */
  45063. alphaCutOff: number;
  45064. /**
  45065. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  45066. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45067. */
  45068. useSpecularOverAlpha: boolean;
  45069. /**
  45070. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45071. */
  45072. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45073. /**
  45074. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45075. */
  45076. useRoughnessFromMetallicTextureAlpha: boolean;
  45077. /**
  45078. * Specifies if the metallic texture contains the roughness information in its green channel.
  45079. */
  45080. useRoughnessFromMetallicTextureGreen: boolean;
  45081. /**
  45082. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45083. */
  45084. useMetallnessFromMetallicTextureBlue: boolean;
  45085. /**
  45086. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45087. */
  45088. useAmbientOcclusionFromMetallicTextureRed: boolean;
  45089. /**
  45090. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45091. */
  45092. useAmbientInGrayScale: boolean;
  45093. /**
  45094. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45095. * The material will try to infer what glossiness each pixel should be.
  45096. */
  45097. useAutoMicroSurfaceFromReflectivityMap: boolean;
  45098. /**
  45099. * BJS is using an harcoded light falloff based on a manually sets up range.
  45100. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45101. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45102. */
  45103. /**
  45104. * BJS is using an harcoded light falloff based on a manually sets up range.
  45105. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  45106. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  45107. */
  45108. usePhysicalLightFalloff: boolean;
  45109. /**
  45110. * In order to support the falloff compatibility with gltf, a special mode has been added
  45111. * to reproduce the gltf light falloff.
  45112. */
  45113. /**
  45114. * In order to support the falloff compatibility with gltf, a special mode has been added
  45115. * to reproduce the gltf light falloff.
  45116. */
  45117. useGLTFLightFalloff: boolean;
  45118. /**
  45119. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45120. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45121. */
  45122. useRadianceOverAlpha: boolean;
  45123. /**
  45124. * Allows using an object space normal map (instead of tangent space).
  45125. */
  45126. useObjectSpaceNormalMap: boolean;
  45127. /**
  45128. * Allows using the bump map in parallax mode.
  45129. */
  45130. useParallax: boolean;
  45131. /**
  45132. * Allows using the bump map in parallax occlusion mode.
  45133. */
  45134. useParallaxOcclusion: boolean;
  45135. /**
  45136. * Controls the scale bias of the parallax mode.
  45137. */
  45138. parallaxScaleBias: number;
  45139. /**
  45140. * If sets to true, disables all the lights affecting the material.
  45141. */
  45142. disableLighting: boolean;
  45143. /**
  45144. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45145. */
  45146. forceIrradianceInFragment: boolean;
  45147. /**
  45148. * Number of Simultaneous lights allowed on the material.
  45149. */
  45150. maxSimultaneousLights: number;
  45151. /**
  45152. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  45153. */
  45154. invertNormalMapX: boolean;
  45155. /**
  45156. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  45157. */
  45158. invertNormalMapY: boolean;
  45159. /**
  45160. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45161. */
  45162. twoSidedLighting: boolean;
  45163. /**
  45164. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45165. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45166. */
  45167. useAlphaFresnel: boolean;
  45168. /**
  45169. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45170. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45171. */
  45172. useLinearAlphaFresnel: boolean;
  45173. /**
  45174. * Let user defines the brdf lookup texture used for IBL.
  45175. * A default 8bit version is embedded but you could point at :
  45176. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  45177. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  45178. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45179. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  45180. */
  45181. environmentBRDFTexture: Nullable<BaseTexture>;
  45182. /**
  45183. * Force normal to face away from face.
  45184. */
  45185. forceNormalForward: boolean;
  45186. /**
  45187. * Enables specular anti aliasing in the PBR shader.
  45188. * It will both interacts on the Geometry for analytical and IBL lighting.
  45189. * It also prefilter the roughness map based on the bump values.
  45190. */
  45191. enableSpecularAntiAliasing: boolean;
  45192. /**
  45193. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45194. * makes the reflect vector face the model (under horizon).
  45195. */
  45196. useHorizonOcclusion: boolean;
  45197. /**
  45198. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45199. * too much the area relying on ambient texture to define their ambient occlusion.
  45200. */
  45201. useRadianceOcclusion: boolean;
  45202. /**
  45203. * If set to true, no lighting calculations will be applied.
  45204. */
  45205. unlit: boolean;
  45206. /**
  45207. * Gets the image processing configuration used either in this material.
  45208. */
  45209. /**
  45210. * Sets the Default image processing configuration used either in the this material.
  45211. *
  45212. * If sets to null, the scene one is in use.
  45213. */
  45214. imageProcessingConfiguration: ImageProcessingConfiguration;
  45215. /**
  45216. * Gets wether the color curves effect is enabled.
  45217. */
  45218. /**
  45219. * Sets wether the color curves effect is enabled.
  45220. */
  45221. cameraColorCurvesEnabled: boolean;
  45222. /**
  45223. * Gets wether the color grading effect is enabled.
  45224. */
  45225. /**
  45226. * Gets wether the color grading effect is enabled.
  45227. */
  45228. cameraColorGradingEnabled: boolean;
  45229. /**
  45230. * Gets wether tonemapping is enabled or not.
  45231. */
  45232. /**
  45233. * Sets wether tonemapping is enabled or not
  45234. */
  45235. cameraToneMappingEnabled: boolean;
  45236. /**
  45237. * The camera exposure used on this material.
  45238. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45239. * This corresponds to a photographic exposure.
  45240. */
  45241. /**
  45242. * The camera exposure used on this material.
  45243. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45244. * This corresponds to a photographic exposure.
  45245. */
  45246. cameraExposure: number;
  45247. /**
  45248. * Gets The camera contrast used on this material.
  45249. */
  45250. /**
  45251. * Sets The camera contrast used on this material.
  45252. */
  45253. cameraContrast: number;
  45254. /**
  45255. * Gets the Color Grading 2D Lookup Texture.
  45256. */
  45257. /**
  45258. * Sets the Color Grading 2D Lookup Texture.
  45259. */
  45260. cameraColorGradingTexture: Nullable<BaseTexture>;
  45261. /**
  45262. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45263. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45264. * 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;
  45265. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45266. */
  45267. /**
  45268. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45269. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45270. * 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;
  45271. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45272. */
  45273. cameraColorCurves: Nullable<ColorCurves>;
  45274. /**
  45275. * Instantiates a new PBRMaterial instance.
  45276. *
  45277. * @param name The material name
  45278. * @param scene The scene the material will be use in.
  45279. */
  45280. constructor(name: string, scene: Scene);
  45281. /**
  45282. * Returns the name of this material class.
  45283. */
  45284. getClassName(): string;
  45285. /**
  45286. * Makes a duplicate of the current material.
  45287. * @param name - name to use for the new material.
  45288. */
  45289. clone(name: string): PBRMaterial;
  45290. /**
  45291. * Serializes this PBR Material.
  45292. * @returns - An object with the serialized material.
  45293. */
  45294. serialize(): any;
  45295. /**
  45296. * Parses a PBR Material from a serialized object.
  45297. * @param source - Serialized object.
  45298. * @param scene - BJS scene instance.
  45299. * @param rootUrl - url for the scene object
  45300. * @returns - PBRMaterial
  45301. */
  45302. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  45303. }
  45304. }
  45305. declare module BABYLON {
  45306. /**
  45307. * Direct draw surface info
  45308. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  45309. */
  45310. export interface DDSInfo {
  45311. /**
  45312. * Width of the texture
  45313. */
  45314. width: number;
  45315. /**
  45316. * Width of the texture
  45317. */
  45318. height: number;
  45319. /**
  45320. * Number of Mipmaps for the texture
  45321. * @see https://en.wikipedia.org/wiki/Mipmap
  45322. */
  45323. mipmapCount: number;
  45324. /**
  45325. * If the textures format is a known fourCC format
  45326. * @see https://www.fourcc.org/
  45327. */
  45328. isFourCC: boolean;
  45329. /**
  45330. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  45331. */
  45332. isRGB: boolean;
  45333. /**
  45334. * If the texture is a lumincance format
  45335. */
  45336. isLuminance: boolean;
  45337. /**
  45338. * If this is a cube texture
  45339. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  45340. */
  45341. isCube: boolean;
  45342. /**
  45343. * If the texture is a compressed format eg. FOURCC_DXT1
  45344. */
  45345. isCompressed: boolean;
  45346. /**
  45347. * The dxgiFormat of the texture
  45348. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  45349. */
  45350. dxgiFormat: number;
  45351. /**
  45352. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  45353. */
  45354. textureType: number;
  45355. /**
  45356. * Sphericle polynomial created for the dds texture
  45357. */
  45358. sphericalPolynomial?: SphericalPolynomial;
  45359. }
  45360. /**
  45361. * Class used to provide DDS decompression tools
  45362. */
  45363. export class DDSTools {
  45364. /**
  45365. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  45366. */
  45367. static StoreLODInAlphaChannel: boolean;
  45368. /**
  45369. * Gets DDS information from an array buffer
  45370. * @param arrayBuffer defines the array buffer to read data from
  45371. * @returns the DDS information
  45372. */
  45373. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  45374. private static _FloatView;
  45375. private static _Int32View;
  45376. private static _ToHalfFloat;
  45377. private static _FromHalfFloat;
  45378. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  45379. private static _GetHalfFloatRGBAArrayBuffer;
  45380. private static _GetFloatRGBAArrayBuffer;
  45381. private static _GetFloatAsUIntRGBAArrayBuffer;
  45382. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  45383. private static _GetRGBAArrayBuffer;
  45384. private static _ExtractLongWordOrder;
  45385. private static _GetRGBArrayBuffer;
  45386. private static _GetLuminanceArrayBuffer;
  45387. /**
  45388. * Uploads DDS Levels to a Babylon Texture
  45389. * @hidden
  45390. */
  45391. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  45392. }
  45393. interface Engine {
  45394. /**
  45395. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  45396. * @param rootUrl defines the url where the file to load is located
  45397. * @param scene defines the current scene
  45398. * @param lodScale defines scale to apply to the mip map selection
  45399. * @param lodOffset defines offset to apply to the mip map selection
  45400. * @param onLoad defines an optional callback raised when the texture is loaded
  45401. * @param onError defines an optional callback raised if there is an issue to load the texture
  45402. * @param format defines the format of the data
  45403. * @param forcedExtension defines the extension to use to pick the right loader
  45404. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  45405. * @returns the cube texture as an InternalTexture
  45406. */
  45407. 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;
  45408. }
  45409. }
  45410. declare module BABYLON {
  45411. /**
  45412. * Implementation of the DDS Texture Loader.
  45413. * @hidden
  45414. */
  45415. export class _DDSTextureLoader implements IInternalTextureLoader {
  45416. /**
  45417. * Defines wether the loader supports cascade loading the different faces.
  45418. */
  45419. readonly supportCascades: boolean;
  45420. /**
  45421. * This returns if the loader support the current file information.
  45422. * @param extension defines the file extension of the file being loaded
  45423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45424. * @param fallback defines the fallback internal texture if any
  45425. * @param isBase64 defines whether the texture is encoded as a base64
  45426. * @param isBuffer defines whether the texture data are stored as a buffer
  45427. * @returns true if the loader can load the specified file
  45428. */
  45429. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45430. /**
  45431. * Transform the url before loading if required.
  45432. * @param rootUrl the url of the texture
  45433. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45434. * @returns the transformed texture
  45435. */
  45436. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45437. /**
  45438. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45439. * @param rootUrl the url of the texture
  45440. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45441. * @returns the fallback texture
  45442. */
  45443. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45444. /**
  45445. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45446. * @param data contains the texture data
  45447. * @param texture defines the BabylonJS internal texture
  45448. * @param createPolynomials will be true if polynomials have been requested
  45449. * @param onLoad defines the callback to trigger once the texture is ready
  45450. * @param onError defines the callback to trigger in case of error
  45451. */
  45452. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45453. /**
  45454. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45455. * @param data contains the texture data
  45456. * @param texture defines the BabylonJS internal texture
  45457. * @param callback defines the method to call once ready to upload
  45458. */
  45459. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45460. }
  45461. }
  45462. declare module BABYLON {
  45463. /** @hidden */
  45464. export var rgbdEncodePixelShader: {
  45465. name: string;
  45466. shader: string;
  45467. };
  45468. }
  45469. declare module BABYLON {
  45470. /**
  45471. * Raw texture data and descriptor sufficient for WebGL texture upload
  45472. */
  45473. export interface EnvironmentTextureInfo {
  45474. /**
  45475. * Version of the environment map
  45476. */
  45477. version: number;
  45478. /**
  45479. * Width of image
  45480. */
  45481. width: number;
  45482. /**
  45483. * Irradiance information stored in the file.
  45484. */
  45485. irradiance: any;
  45486. /**
  45487. * Specular information stored in the file.
  45488. */
  45489. specular: any;
  45490. }
  45491. /**
  45492. * Sets of helpers addressing the serialization and deserialization of environment texture
  45493. * stored in a BabylonJS env file.
  45494. * Those files are usually stored as .env files.
  45495. */
  45496. export class EnvironmentTextureTools {
  45497. /**
  45498. * Magic number identifying the env file.
  45499. */
  45500. private static _MagicBytes;
  45501. /**
  45502. * Gets the environment info from an env file.
  45503. * @param data The array buffer containing the .env bytes.
  45504. * @returns the environment file info (the json header) if successfully parsed.
  45505. */
  45506. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  45507. /**
  45508. * Creates an environment texture from a loaded cube texture.
  45509. * @param texture defines the cube texture to convert in env file
  45510. * @return a promise containing the environment data if succesfull.
  45511. */
  45512. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  45513. /**
  45514. * Creates a JSON representation of the spherical data.
  45515. * @param texture defines the texture containing the polynomials
  45516. * @return the JSON representation of the spherical info
  45517. */
  45518. private static _CreateEnvTextureIrradiance;
  45519. /**
  45520. * Uploads the texture info contained in the env file to the GPU.
  45521. * @param texture defines the internal texture to upload to
  45522. * @param arrayBuffer defines the buffer cotaining the data to load
  45523. * @param info defines the texture info retrieved through the GetEnvInfo method
  45524. * @returns a promise
  45525. */
  45526. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  45527. /**
  45528. * Uploads the levels of image data to the GPU.
  45529. * @param texture defines the internal texture to upload to
  45530. * @param imageData defines the array buffer views of image data [mipmap][face]
  45531. * @returns a promise
  45532. */
  45533. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  45534. /**
  45535. * Uploads spherical polynomials information to the texture.
  45536. * @param texture defines the texture we are trying to upload the information to
  45537. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  45538. */
  45539. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  45540. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  45541. }
  45542. }
  45543. declare module BABYLON {
  45544. /**
  45545. * Implementation of the ENV Texture Loader.
  45546. * @hidden
  45547. */
  45548. export class _ENVTextureLoader implements IInternalTextureLoader {
  45549. /**
  45550. * Defines wether the loader supports cascade loading the different faces.
  45551. */
  45552. readonly supportCascades: boolean;
  45553. /**
  45554. * This returns if the loader support the current file information.
  45555. * @param extension defines the file extension of the file being loaded
  45556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45557. * @param fallback defines the fallback internal texture if any
  45558. * @param isBase64 defines whether the texture is encoded as a base64
  45559. * @param isBuffer defines whether the texture data are stored as a buffer
  45560. * @returns true if the loader can load the specified file
  45561. */
  45562. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45563. /**
  45564. * Transform the url before loading if required.
  45565. * @param rootUrl the url of the texture
  45566. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45567. * @returns the transformed texture
  45568. */
  45569. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45570. /**
  45571. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45572. * @param rootUrl the url of the texture
  45573. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45574. * @returns the fallback texture
  45575. */
  45576. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45577. /**
  45578. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45579. * @param data contains the texture data
  45580. * @param texture defines the BabylonJS internal texture
  45581. * @param createPolynomials will be true if polynomials have been requested
  45582. * @param onLoad defines the callback to trigger once the texture is ready
  45583. * @param onError defines the callback to trigger in case of error
  45584. */
  45585. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45586. /**
  45587. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45588. * @param data contains the texture data
  45589. * @param texture defines the BabylonJS internal texture
  45590. * @param callback defines the method to call once ready to upload
  45591. */
  45592. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  45593. }
  45594. }
  45595. declare module BABYLON {
  45596. /**
  45597. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  45598. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  45599. */
  45600. export class KhronosTextureContainer {
  45601. /** contents of the KTX container file */
  45602. arrayBuffer: any;
  45603. private static HEADER_LEN;
  45604. private static COMPRESSED_2D;
  45605. private static COMPRESSED_3D;
  45606. private static TEX_2D;
  45607. private static TEX_3D;
  45608. /**
  45609. * Gets the openGL type
  45610. */
  45611. glType: number;
  45612. /**
  45613. * Gets the openGL type size
  45614. */
  45615. glTypeSize: number;
  45616. /**
  45617. * Gets the openGL format
  45618. */
  45619. glFormat: number;
  45620. /**
  45621. * Gets the openGL internal format
  45622. */
  45623. glInternalFormat: number;
  45624. /**
  45625. * Gets the base internal format
  45626. */
  45627. glBaseInternalFormat: number;
  45628. /**
  45629. * Gets image width in pixel
  45630. */
  45631. pixelWidth: number;
  45632. /**
  45633. * Gets image height in pixel
  45634. */
  45635. pixelHeight: number;
  45636. /**
  45637. * Gets image depth in pixels
  45638. */
  45639. pixelDepth: number;
  45640. /**
  45641. * Gets the number of array elements
  45642. */
  45643. numberOfArrayElements: number;
  45644. /**
  45645. * Gets the number of faces
  45646. */
  45647. numberOfFaces: number;
  45648. /**
  45649. * Gets the number of mipmap levels
  45650. */
  45651. numberOfMipmapLevels: number;
  45652. /**
  45653. * Gets the bytes of key value data
  45654. */
  45655. bytesOfKeyValueData: number;
  45656. /**
  45657. * Gets the load type
  45658. */
  45659. loadType: number;
  45660. /**
  45661. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  45662. */
  45663. isInvalid: boolean;
  45664. /**
  45665. * Creates a new KhronosTextureContainer
  45666. * @param arrayBuffer contents of the KTX container file
  45667. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  45668. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  45669. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  45670. */
  45671. constructor(
  45672. /** contents of the KTX container file */
  45673. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  45674. /**
  45675. * Uploads KTX content to a Babylon Texture.
  45676. * It is assumed that the texture has already been created & is currently bound
  45677. * @hidden
  45678. */
  45679. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  45680. private _upload2DCompressedLevels;
  45681. }
  45682. }
  45683. declare module BABYLON {
  45684. /**
  45685. * Implementation of the KTX Texture Loader.
  45686. * @hidden
  45687. */
  45688. export class _KTXTextureLoader implements IInternalTextureLoader {
  45689. /**
  45690. * Defines wether the loader supports cascade loading the different faces.
  45691. */
  45692. readonly supportCascades: boolean;
  45693. /**
  45694. * This returns if the loader support the current file information.
  45695. * @param extension defines the file extension of the file being loaded
  45696. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45697. * @param fallback defines the fallback internal texture if any
  45698. * @param isBase64 defines whether the texture is encoded as a base64
  45699. * @param isBuffer defines whether the texture data are stored as a buffer
  45700. * @returns true if the loader can load the specified file
  45701. */
  45702. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  45703. /**
  45704. * Transform the url before loading if required.
  45705. * @param rootUrl the url of the texture
  45706. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45707. * @returns the transformed texture
  45708. */
  45709. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  45710. /**
  45711. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  45712. * @param rootUrl the url of the texture
  45713. * @param textureFormatInUse defines the current compressed format in use iun the engine
  45714. * @returns the fallback texture
  45715. */
  45716. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  45717. /**
  45718. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  45719. * @param data contains the texture data
  45720. * @param texture defines the BabylonJS internal texture
  45721. * @param createPolynomials will be true if polynomials have been requested
  45722. * @param onLoad defines the callback to trigger once the texture is ready
  45723. * @param onError defines the callback to trigger in case of error
  45724. */
  45725. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  45726. /**
  45727. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  45728. * @param data contains the texture data
  45729. * @param texture defines the BabylonJS internal texture
  45730. * @param callback defines the method to call once ready to upload
  45731. */
  45732. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  45733. }
  45734. }
  45735. declare module BABYLON {
  45736. /** @hidden */
  45737. export var _forceSceneHelpersToBundle: boolean;
  45738. interface Scene {
  45739. /**
  45740. * Creates a default light for the scene.
  45741. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  45742. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  45743. */
  45744. createDefaultLight(replace?: boolean): void;
  45745. /**
  45746. * Creates a default camera for the scene.
  45747. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  45748. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45749. * @param replace has default false, when true replaces the active camera in the scene
  45750. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  45751. */
  45752. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45753. /**
  45754. * Creates a default camera and a default light.
  45755. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  45756. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  45757. * @param replace has the default false, when true replaces the active camera/light in the scene
  45758. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  45759. */
  45760. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  45761. /**
  45762. * Creates a new sky box
  45763. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  45764. * @param environmentTexture defines the texture to use as environment texture
  45765. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  45766. * @param scale defines the overall scale of the skybox
  45767. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  45768. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  45769. * @returns a new mesh holding the sky box
  45770. */
  45771. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  45772. /**
  45773. * Creates a new environment
  45774. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  45775. * @param options defines the options you can use to configure the environment
  45776. * @returns the new EnvironmentHelper
  45777. */
  45778. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  45779. /**
  45780. * Creates a new VREXperienceHelper
  45781. * @see http://doc.babylonjs.com/how_to/webvr_helper
  45782. * @param webVROptions defines the options used to create the new VREXperienceHelper
  45783. * @returns a new VREXperienceHelper
  45784. */
  45785. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  45786. /**
  45787. * Creates a new XREXperienceHelper
  45788. * @see http://doc.babylonjs.com/how_to/webxr
  45789. * @returns a promise for a new XREXperienceHelper
  45790. */
  45791. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  45792. }
  45793. }
  45794. declare module BABYLON {
  45795. /**
  45796. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  45797. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  45798. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  45799. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45800. */
  45801. export class VideoDome extends TransformNode {
  45802. /**
  45803. * Define the video source as a Monoscopic panoramic 360 video.
  45804. */
  45805. static readonly MODE_MONOSCOPIC: number;
  45806. /**
  45807. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45808. */
  45809. static readonly MODE_TOPBOTTOM: number;
  45810. /**
  45811. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45812. */
  45813. static readonly MODE_SIDEBYSIDE: number;
  45814. private _useDirectMapping;
  45815. /**
  45816. * The video texture being displayed on the sphere
  45817. */
  45818. protected _videoTexture: VideoTexture;
  45819. /**
  45820. * Gets the video texture being displayed on the sphere
  45821. */
  45822. readonly videoTexture: VideoTexture;
  45823. /**
  45824. * The skybox material
  45825. */
  45826. protected _material: BackgroundMaterial;
  45827. /**
  45828. * The surface used for the skybox
  45829. */
  45830. protected _mesh: Mesh;
  45831. /**
  45832. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45833. * Also see the options.resolution property.
  45834. */
  45835. fovMultiplier: number;
  45836. private _videoMode;
  45837. /**
  45838. * Gets or set the current video mode for the video. It can be:
  45839. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  45840. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  45841. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  45842. */
  45843. videoMode: number;
  45844. /**
  45845. * Oberserver used in Stereoscopic VR Mode.
  45846. */
  45847. private _onBeforeCameraRenderObserver;
  45848. /**
  45849. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  45850. * @param name Element's name, child elements will append suffixes for their own names.
  45851. * @param urlsOrVideo defines the url(s) or the video element to use
  45852. * @param options An object containing optional or exposed sub element properties
  45853. */
  45854. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  45855. resolution?: number;
  45856. clickToPlay?: boolean;
  45857. autoPlay?: boolean;
  45858. loop?: boolean;
  45859. size?: number;
  45860. poster?: string;
  45861. faceForward?: boolean;
  45862. useDirectMapping?: boolean;
  45863. }, scene: Scene);
  45864. private _changeVideoMode;
  45865. /**
  45866. * Releases resources associated with this node.
  45867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45869. */
  45870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45871. }
  45872. }
  45873. declare module BABYLON {
  45874. /**
  45875. * This class can be used to get instrumentation data from a Babylon engine
  45876. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45877. */
  45878. export class EngineInstrumentation implements IDisposable {
  45879. /**
  45880. * Define the instrumented engine.
  45881. */
  45882. engine: Engine;
  45883. private _captureGPUFrameTime;
  45884. private _gpuFrameTimeToken;
  45885. private _gpuFrameTime;
  45886. private _captureShaderCompilationTime;
  45887. private _shaderCompilationTime;
  45888. private _onBeginFrameObserver;
  45889. private _onEndFrameObserver;
  45890. private _onBeforeShaderCompilationObserver;
  45891. private _onAfterShaderCompilationObserver;
  45892. /**
  45893. * Gets the perf counter used for GPU frame time
  45894. */
  45895. readonly gpuFrameTimeCounter: PerfCounter;
  45896. /**
  45897. * Gets the GPU frame time capture status
  45898. */
  45899. /**
  45900. * Enable or disable the GPU frame time capture
  45901. */
  45902. captureGPUFrameTime: boolean;
  45903. /**
  45904. * Gets the perf counter used for shader compilation time
  45905. */
  45906. readonly shaderCompilationTimeCounter: PerfCounter;
  45907. /**
  45908. * Gets the shader compilation time capture status
  45909. */
  45910. /**
  45911. * Enable or disable the shader compilation time capture
  45912. */
  45913. captureShaderCompilationTime: boolean;
  45914. /**
  45915. * Instantiates a new engine instrumentation.
  45916. * This class can be used to get instrumentation data from a Babylon engine
  45917. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  45918. * @param engine Defines the engine to instrument
  45919. */
  45920. constructor(
  45921. /**
  45922. * Define the instrumented engine.
  45923. */
  45924. engine: Engine);
  45925. /**
  45926. * Dispose and release associated resources.
  45927. */
  45928. dispose(): void;
  45929. }
  45930. }
  45931. declare module BABYLON {
  45932. /**
  45933. * This class can be used to get instrumentation data from a Babylon engine
  45934. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  45935. */
  45936. export class SceneInstrumentation implements IDisposable {
  45937. /**
  45938. * Defines the scene to instrument
  45939. */
  45940. scene: Scene;
  45941. private _captureActiveMeshesEvaluationTime;
  45942. private _activeMeshesEvaluationTime;
  45943. private _captureRenderTargetsRenderTime;
  45944. private _renderTargetsRenderTime;
  45945. private _captureFrameTime;
  45946. private _frameTime;
  45947. private _captureRenderTime;
  45948. private _renderTime;
  45949. private _captureInterFrameTime;
  45950. private _interFrameTime;
  45951. private _captureParticlesRenderTime;
  45952. private _particlesRenderTime;
  45953. private _captureSpritesRenderTime;
  45954. private _spritesRenderTime;
  45955. private _capturePhysicsTime;
  45956. private _physicsTime;
  45957. private _captureAnimationsTime;
  45958. private _animationsTime;
  45959. private _captureCameraRenderTime;
  45960. private _cameraRenderTime;
  45961. private _onBeforeActiveMeshesEvaluationObserver;
  45962. private _onAfterActiveMeshesEvaluationObserver;
  45963. private _onBeforeRenderTargetsRenderObserver;
  45964. private _onAfterRenderTargetsRenderObserver;
  45965. private _onAfterRenderObserver;
  45966. private _onBeforeDrawPhaseObserver;
  45967. private _onAfterDrawPhaseObserver;
  45968. private _onBeforeAnimationsObserver;
  45969. private _onBeforeParticlesRenderingObserver;
  45970. private _onAfterParticlesRenderingObserver;
  45971. private _onBeforeSpritesRenderingObserver;
  45972. private _onAfterSpritesRenderingObserver;
  45973. private _onBeforePhysicsObserver;
  45974. private _onAfterPhysicsObserver;
  45975. private _onAfterAnimationsObserver;
  45976. private _onBeforeCameraRenderObserver;
  45977. private _onAfterCameraRenderObserver;
  45978. /**
  45979. * Gets the perf counter used for active meshes evaluation time
  45980. */
  45981. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  45982. /**
  45983. * Gets the active meshes evaluation time capture status
  45984. */
  45985. /**
  45986. * Enable or disable the active meshes evaluation time capture
  45987. */
  45988. captureActiveMeshesEvaluationTime: boolean;
  45989. /**
  45990. * Gets the perf counter used for render targets render time
  45991. */
  45992. readonly renderTargetsRenderTimeCounter: PerfCounter;
  45993. /**
  45994. * Gets the render targets render time capture status
  45995. */
  45996. /**
  45997. * Enable or disable the render targets render time capture
  45998. */
  45999. captureRenderTargetsRenderTime: boolean;
  46000. /**
  46001. * Gets the perf counter used for particles render time
  46002. */
  46003. readonly particlesRenderTimeCounter: PerfCounter;
  46004. /**
  46005. * Gets the particles render time capture status
  46006. */
  46007. /**
  46008. * Enable or disable the particles render time capture
  46009. */
  46010. captureParticlesRenderTime: boolean;
  46011. /**
  46012. * Gets the perf counter used for sprites render time
  46013. */
  46014. readonly spritesRenderTimeCounter: PerfCounter;
  46015. /**
  46016. * Gets the sprites render time capture status
  46017. */
  46018. /**
  46019. * Enable or disable the sprites render time capture
  46020. */
  46021. captureSpritesRenderTime: boolean;
  46022. /**
  46023. * Gets the perf counter used for physics time
  46024. */
  46025. readonly physicsTimeCounter: PerfCounter;
  46026. /**
  46027. * Gets the physics time capture status
  46028. */
  46029. /**
  46030. * Enable or disable the physics time capture
  46031. */
  46032. capturePhysicsTime: boolean;
  46033. /**
  46034. * Gets the perf counter used for animations time
  46035. */
  46036. readonly animationsTimeCounter: PerfCounter;
  46037. /**
  46038. * Gets the animations time capture status
  46039. */
  46040. /**
  46041. * Enable or disable the animations time capture
  46042. */
  46043. captureAnimationsTime: boolean;
  46044. /**
  46045. * Gets the perf counter used for frame time capture
  46046. */
  46047. readonly frameTimeCounter: PerfCounter;
  46048. /**
  46049. * Gets the frame time capture status
  46050. */
  46051. /**
  46052. * Enable or disable the frame time capture
  46053. */
  46054. captureFrameTime: boolean;
  46055. /**
  46056. * Gets the perf counter used for inter-frames time capture
  46057. */
  46058. readonly interFrameTimeCounter: PerfCounter;
  46059. /**
  46060. * Gets the inter-frames time capture status
  46061. */
  46062. /**
  46063. * Enable or disable the inter-frames time capture
  46064. */
  46065. captureInterFrameTime: boolean;
  46066. /**
  46067. * Gets the perf counter used for render time capture
  46068. */
  46069. readonly renderTimeCounter: PerfCounter;
  46070. /**
  46071. * Gets the render time capture status
  46072. */
  46073. /**
  46074. * Enable or disable the render time capture
  46075. */
  46076. captureRenderTime: boolean;
  46077. /**
  46078. * Gets the perf counter used for camera render time capture
  46079. */
  46080. readonly cameraRenderTimeCounter: PerfCounter;
  46081. /**
  46082. * Gets the camera render time capture status
  46083. */
  46084. /**
  46085. * Enable or disable the camera render time capture
  46086. */
  46087. captureCameraRenderTime: boolean;
  46088. /**
  46089. * Gets the perf counter used for draw calls
  46090. */
  46091. readonly drawCallsCounter: PerfCounter;
  46092. /**
  46093. * Instantiates a new scene instrumentation.
  46094. * This class can be used to get instrumentation data from a Babylon engine
  46095. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  46096. * @param scene Defines the scene to instrument
  46097. */
  46098. constructor(
  46099. /**
  46100. * Defines the scene to instrument
  46101. */
  46102. scene: Scene);
  46103. /**
  46104. * Dispose and release associated resources.
  46105. */
  46106. dispose(): void;
  46107. }
  46108. }
  46109. declare module BABYLON {
  46110. /** @hidden */
  46111. export var glowMapGenerationPixelShader: {
  46112. name: string;
  46113. shader: string;
  46114. };
  46115. }
  46116. declare module BABYLON {
  46117. /** @hidden */
  46118. export var glowMapGenerationVertexShader: {
  46119. name: string;
  46120. shader: string;
  46121. };
  46122. }
  46123. declare module BABYLON {
  46124. /**
  46125. * Effect layer options. This helps customizing the behaviour
  46126. * of the effect layer.
  46127. */
  46128. export interface IEffectLayerOptions {
  46129. /**
  46130. * Multiplication factor apply to the canvas size to compute the render target size
  46131. * used to generated the objects (the smaller the faster).
  46132. */
  46133. mainTextureRatio: number;
  46134. /**
  46135. * Enforces a fixed size texture to ensure effect stability across devices.
  46136. */
  46137. mainTextureFixedSize?: number;
  46138. /**
  46139. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  46140. */
  46141. alphaBlendingMode: number;
  46142. /**
  46143. * The camera attached to the layer.
  46144. */
  46145. camera: Nullable<Camera>;
  46146. /**
  46147. * The rendering group to draw the layer in.
  46148. */
  46149. renderingGroupId: number;
  46150. }
  46151. /**
  46152. * The effect layer Helps adding post process effect blended with the main pass.
  46153. *
  46154. * This can be for instance use to generate glow or higlight effects on the scene.
  46155. *
  46156. * The effect layer class can not be used directly and is intented to inherited from to be
  46157. * customized per effects.
  46158. */
  46159. export abstract class EffectLayer {
  46160. private _vertexBuffers;
  46161. private _indexBuffer;
  46162. private _cachedDefines;
  46163. private _effectLayerMapGenerationEffect;
  46164. private _effectLayerOptions;
  46165. private _mergeEffect;
  46166. protected _scene: Scene;
  46167. protected _engine: Engine;
  46168. protected _maxSize: number;
  46169. protected _mainTextureDesiredSize: ISize;
  46170. protected _mainTexture: RenderTargetTexture;
  46171. protected _shouldRender: boolean;
  46172. protected _postProcesses: PostProcess[];
  46173. protected _textures: BaseTexture[];
  46174. protected _emissiveTextureAndColor: {
  46175. texture: Nullable<BaseTexture>;
  46176. color: Color4;
  46177. };
  46178. /**
  46179. * The name of the layer
  46180. */
  46181. name: string;
  46182. /**
  46183. * The clear color of the texture used to generate the glow map.
  46184. */
  46185. neutralColor: Color4;
  46186. /**
  46187. * Specifies wether the highlight layer is enabled or not.
  46188. */
  46189. isEnabled: boolean;
  46190. /**
  46191. * Gets the camera attached to the layer.
  46192. */
  46193. readonly camera: Nullable<Camera>;
  46194. /**
  46195. * Gets the rendering group id the layer should render in.
  46196. */
  46197. readonly renderingGroupId: number;
  46198. /**
  46199. * An event triggered when the effect layer has been disposed.
  46200. */
  46201. onDisposeObservable: Observable<EffectLayer>;
  46202. /**
  46203. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  46204. */
  46205. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  46206. /**
  46207. * An event triggered when the generated texture is being merged in the scene.
  46208. */
  46209. onBeforeComposeObservable: Observable<EffectLayer>;
  46210. /**
  46211. * An event triggered when the generated texture has been merged in the scene.
  46212. */
  46213. onAfterComposeObservable: Observable<EffectLayer>;
  46214. /**
  46215. * An event triggered when the efffect layer changes its size.
  46216. */
  46217. onSizeChangedObservable: Observable<EffectLayer>;
  46218. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  46219. /**
  46220. * Instantiates a new effect Layer and references it in the scene.
  46221. * @param name The name of the layer
  46222. * @param scene The scene to use the layer in
  46223. */
  46224. constructor(
  46225. /** The Friendly of the effect in the scene */
  46226. name: string, scene: Scene);
  46227. /**
  46228. * Get the effect name of the layer.
  46229. * @return The effect name
  46230. */
  46231. abstract getEffectName(): string;
  46232. /**
  46233. * Checks for the readiness of the element composing the layer.
  46234. * @param subMesh the mesh to check for
  46235. * @param useInstances specify wether or not to use instances to render the mesh
  46236. * @return true if ready otherwise, false
  46237. */
  46238. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46239. /**
  46240. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46241. * @returns true if the effect requires stencil during the main canvas render pass.
  46242. */
  46243. abstract needStencil(): boolean;
  46244. /**
  46245. * Create the merge effect. This is the shader use to blit the information back
  46246. * to the main canvas at the end of the scene rendering.
  46247. * @returns The effect containing the shader used to merge the effect on the main canvas
  46248. */
  46249. protected abstract _createMergeEffect(): Effect;
  46250. /**
  46251. * Creates the render target textures and post processes used in the effect layer.
  46252. */
  46253. protected abstract _createTextureAndPostProcesses(): void;
  46254. /**
  46255. * Implementation specific of rendering the generating effect on the main canvas.
  46256. * @param effect The effect used to render through
  46257. */
  46258. protected abstract _internalRender(effect: Effect): void;
  46259. /**
  46260. * Sets the required values for both the emissive texture and and the main color.
  46261. */
  46262. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46263. /**
  46264. * Free any resources and references associated to a mesh.
  46265. * Internal use
  46266. * @param mesh The mesh to free.
  46267. */
  46268. abstract _disposeMesh(mesh: Mesh): void;
  46269. /**
  46270. * Serializes this layer (Glow or Highlight for example)
  46271. * @returns a serialized layer object
  46272. */
  46273. abstract serialize?(): any;
  46274. /**
  46275. * Initializes the effect layer with the required options.
  46276. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  46277. */
  46278. protected _init(options: Partial<IEffectLayerOptions>): void;
  46279. /**
  46280. * Generates the index buffer of the full screen quad blending to the main canvas.
  46281. */
  46282. private _generateIndexBuffer;
  46283. /**
  46284. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  46285. */
  46286. private _generateVertexBuffer;
  46287. /**
  46288. * Sets the main texture desired size which is the closest power of two
  46289. * of the engine canvas size.
  46290. */
  46291. private _setMainTextureSize;
  46292. /**
  46293. * Creates the main texture for the effect layer.
  46294. */
  46295. protected _createMainTexture(): void;
  46296. /**
  46297. * Adds specific effects defines.
  46298. * @param defines The defines to add specifics to.
  46299. */
  46300. protected _addCustomEffectDefines(defines: string[]): void;
  46301. /**
  46302. * Checks for the readiness of the element composing the layer.
  46303. * @param subMesh the mesh to check for
  46304. * @param useInstances specify wether or not to use instances to render the mesh
  46305. * @param emissiveTexture the associated emissive texture used to generate the glow
  46306. * @return true if ready otherwise, false
  46307. */
  46308. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  46309. /**
  46310. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  46311. */
  46312. render(): void;
  46313. /**
  46314. * Determine if a given mesh will be used in the current effect.
  46315. * @param mesh mesh to test
  46316. * @returns true if the mesh will be used
  46317. */
  46318. hasMesh(mesh: AbstractMesh): boolean;
  46319. /**
  46320. * Returns true if the layer contains information to display, otherwise false.
  46321. * @returns true if the glow layer should be rendered
  46322. */
  46323. shouldRender(): boolean;
  46324. /**
  46325. * Returns true if the mesh should render, otherwise false.
  46326. * @param mesh The mesh to render
  46327. * @returns true if it should render otherwise false
  46328. */
  46329. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  46330. /**
  46331. * Returns true if the mesh can be rendered, otherwise false.
  46332. * @param mesh The mesh to render
  46333. * @param material The material used on the mesh
  46334. * @returns true if it can be rendered otherwise false
  46335. */
  46336. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46337. /**
  46338. * Returns true if the mesh should render, otherwise false.
  46339. * @param mesh The mesh to render
  46340. * @returns true if it should render otherwise false
  46341. */
  46342. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  46343. /**
  46344. * Renders the submesh passed in parameter to the generation map.
  46345. */
  46346. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  46347. /**
  46348. * Rebuild the required buffers.
  46349. * @hidden Internal use only.
  46350. */ private _rebuild(): void;
  46351. /**
  46352. * Dispose only the render target textures and post process.
  46353. */
  46354. private _disposeTextureAndPostProcesses;
  46355. /**
  46356. * Dispose the highlight layer and free resources.
  46357. */
  46358. dispose(): void;
  46359. /**
  46360. * Gets the class name of the effect layer
  46361. * @returns the string with the class name of the effect layer
  46362. */
  46363. getClassName(): string;
  46364. /**
  46365. * Creates an effect layer from parsed effect layer data
  46366. * @param parsedEffectLayer defines effect layer data
  46367. * @param scene defines the current scene
  46368. * @param rootUrl defines the root URL containing the effect layer information
  46369. * @returns a parsed effect Layer
  46370. */
  46371. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  46372. }
  46373. }
  46374. declare module BABYLON {
  46375. interface AbstractScene {
  46376. /**
  46377. * The list of effect layers (highlights/glow) added to the scene
  46378. * @see http://doc.babylonjs.com/how_to/highlight_layer
  46379. * @see http://doc.babylonjs.com/how_to/glow_layer
  46380. */
  46381. effectLayers: Array<EffectLayer>;
  46382. /**
  46383. * Removes the given effect layer from this scene.
  46384. * @param toRemove defines the effect layer to remove
  46385. * @returns the index of the removed effect layer
  46386. */
  46387. removeEffectLayer(toRemove: EffectLayer): number;
  46388. /**
  46389. * Adds the given effect layer to this scene
  46390. * @param newEffectLayer defines the effect layer to add
  46391. */
  46392. addEffectLayer(newEffectLayer: EffectLayer): void;
  46393. }
  46394. /**
  46395. * Defines the layer scene component responsible to manage any effect layers
  46396. * in a given scene.
  46397. */
  46398. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  46399. /**
  46400. * The component name helpfull to identify the component in the list of scene components.
  46401. */
  46402. readonly name: string;
  46403. /**
  46404. * The scene the component belongs to.
  46405. */
  46406. scene: Scene;
  46407. private _engine;
  46408. private _renderEffects;
  46409. private _needStencil;
  46410. private _previousStencilState;
  46411. /**
  46412. * Creates a new instance of the component for the given scene
  46413. * @param scene Defines the scene to register the component in
  46414. */
  46415. constructor(scene: Scene);
  46416. /**
  46417. * Registers the component in a given scene
  46418. */
  46419. register(): void;
  46420. /**
  46421. * Rebuilds the elements related to this component in case of
  46422. * context lost for instance.
  46423. */
  46424. rebuild(): void;
  46425. /**
  46426. * Serializes the component data to the specified json object
  46427. * @param serializationObject The object to serialize to
  46428. */
  46429. serialize(serializationObject: any): void;
  46430. /**
  46431. * Adds all the elements from the container to the scene
  46432. * @param container the container holding the elements
  46433. */
  46434. addFromContainer(container: AbstractScene): void;
  46435. /**
  46436. * Removes all the elements in the container from the scene
  46437. * @param container contains the elements to remove
  46438. * @param dispose if the removed element should be disposed (default: false)
  46439. */
  46440. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46441. /**
  46442. * Disposes the component and the associated ressources.
  46443. */
  46444. dispose(): void;
  46445. private _isReadyForMesh;
  46446. private _renderMainTexture;
  46447. private _setStencil;
  46448. private _setStencilBack;
  46449. private _draw;
  46450. private _drawCamera;
  46451. private _drawRenderingGroup;
  46452. }
  46453. }
  46454. declare module BABYLON {
  46455. /** @hidden */
  46456. export var glowMapMergePixelShader: {
  46457. name: string;
  46458. shader: string;
  46459. };
  46460. }
  46461. declare module BABYLON {
  46462. /** @hidden */
  46463. export var glowMapMergeVertexShader: {
  46464. name: string;
  46465. shader: string;
  46466. };
  46467. }
  46468. declare module BABYLON {
  46469. interface AbstractScene {
  46470. /**
  46471. * Return a the first highlight layer of the scene with a given name.
  46472. * @param name The name of the highlight layer to look for.
  46473. * @return The highlight layer if found otherwise null.
  46474. */
  46475. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  46476. }
  46477. /**
  46478. * Glow layer options. This helps customizing the behaviour
  46479. * of the glow layer.
  46480. */
  46481. export interface IGlowLayerOptions {
  46482. /**
  46483. * Multiplication factor apply to the canvas size to compute the render target size
  46484. * used to generated the glowing objects (the smaller the faster).
  46485. */
  46486. mainTextureRatio: number;
  46487. /**
  46488. * Enforces a fixed size texture to ensure resize independant blur.
  46489. */
  46490. mainTextureFixedSize?: number;
  46491. /**
  46492. * How big is the kernel of the blur texture.
  46493. */
  46494. blurKernelSize: number;
  46495. /**
  46496. * The camera attached to the layer.
  46497. */
  46498. camera: Nullable<Camera>;
  46499. /**
  46500. * Enable MSAA by chosing the number of samples.
  46501. */
  46502. mainTextureSamples?: number;
  46503. /**
  46504. * The rendering group to draw the layer in.
  46505. */
  46506. renderingGroupId: number;
  46507. }
  46508. /**
  46509. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  46510. *
  46511. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46512. * glowy meshes to your scene.
  46513. *
  46514. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  46515. */
  46516. export class GlowLayer extends EffectLayer {
  46517. /**
  46518. * Effect Name of the layer.
  46519. */
  46520. static readonly EffectName: string;
  46521. /**
  46522. * The default blur kernel size used for the glow.
  46523. */
  46524. static DefaultBlurKernelSize: number;
  46525. /**
  46526. * The default texture size ratio used for the glow.
  46527. */
  46528. static DefaultTextureRatio: number;
  46529. /**
  46530. * Sets the kernel size of the blur.
  46531. */
  46532. /**
  46533. * Gets the kernel size of the blur.
  46534. */
  46535. blurKernelSize: number;
  46536. /**
  46537. * Sets the glow intensity.
  46538. */
  46539. /**
  46540. * Gets the glow intensity.
  46541. */
  46542. intensity: number;
  46543. private _options;
  46544. private _intensity;
  46545. private _horizontalBlurPostprocess1;
  46546. private _verticalBlurPostprocess1;
  46547. private _horizontalBlurPostprocess2;
  46548. private _verticalBlurPostprocess2;
  46549. private _blurTexture1;
  46550. private _blurTexture2;
  46551. private _postProcesses1;
  46552. private _postProcesses2;
  46553. private _includedOnlyMeshes;
  46554. private _excludedMeshes;
  46555. /**
  46556. * Callback used to let the user override the color selection on a per mesh basis
  46557. */
  46558. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  46559. /**
  46560. * Callback used to let the user override the texture selection on a per mesh basis
  46561. */
  46562. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  46563. /**
  46564. * Instantiates a new glow Layer and references it to the scene.
  46565. * @param name The name of the layer
  46566. * @param scene The scene to use the layer in
  46567. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  46568. */
  46569. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  46570. /**
  46571. * Get the effect name of the layer.
  46572. * @return The effect name
  46573. */
  46574. getEffectName(): string;
  46575. /**
  46576. * Create the merge effect. This is the shader use to blit the information back
  46577. * to the main canvas at the end of the scene rendering.
  46578. */
  46579. protected _createMergeEffect(): Effect;
  46580. /**
  46581. * Creates the render target textures and post processes used in the glow layer.
  46582. */
  46583. protected _createTextureAndPostProcesses(): void;
  46584. /**
  46585. * Checks for the readiness of the element composing the layer.
  46586. * @param subMesh the mesh to check for
  46587. * @param useInstances specify wether or not to use instances to render the mesh
  46588. * @param emissiveTexture the associated emissive texture used to generate the glow
  46589. * @return true if ready otherwise, false
  46590. */
  46591. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46592. /**
  46593. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46594. */
  46595. needStencil(): boolean;
  46596. /**
  46597. * Returns true if the mesh can be rendered, otherwise false.
  46598. * @param mesh The mesh to render
  46599. * @param material The material used on the mesh
  46600. * @returns true if it can be rendered otherwise false
  46601. */
  46602. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  46603. /**
  46604. * Implementation specific of rendering the generating effect on the main canvas.
  46605. * @param effect The effect used to render through
  46606. */
  46607. protected _internalRender(effect: Effect): void;
  46608. /**
  46609. * Sets the required values for both the emissive texture and and the main color.
  46610. */
  46611. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46612. /**
  46613. * Returns true if the mesh should render, otherwise false.
  46614. * @param mesh The mesh to render
  46615. * @returns true if it should render otherwise false
  46616. */
  46617. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46618. /**
  46619. * Adds specific effects defines.
  46620. * @param defines The defines to add specifics to.
  46621. */
  46622. protected _addCustomEffectDefines(defines: string[]): void;
  46623. /**
  46624. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  46625. * @param mesh The mesh to exclude from the glow layer
  46626. */
  46627. addExcludedMesh(mesh: Mesh): void;
  46628. /**
  46629. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  46630. * @param mesh The mesh to remove
  46631. */
  46632. removeExcludedMesh(mesh: Mesh): void;
  46633. /**
  46634. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  46635. * @param mesh The mesh to include in the glow layer
  46636. */
  46637. addIncludedOnlyMesh(mesh: Mesh): void;
  46638. /**
  46639. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  46640. * @param mesh The mesh to remove
  46641. */
  46642. removeIncludedOnlyMesh(mesh: Mesh): void;
  46643. /**
  46644. * Determine if a given mesh will be used in the glow layer
  46645. * @param mesh The mesh to test
  46646. * @returns true if the mesh will be highlighted by the current glow layer
  46647. */
  46648. hasMesh(mesh: AbstractMesh): boolean;
  46649. /**
  46650. * Free any resources and references associated to a mesh.
  46651. * Internal use
  46652. * @param mesh The mesh to free.
  46653. * @hidden
  46654. */ private _disposeMesh(mesh: Mesh): void;
  46655. /**
  46656. * Gets the class name of the effect layer
  46657. * @returns the string with the class name of the effect layer
  46658. */
  46659. getClassName(): string;
  46660. /**
  46661. * Serializes this glow layer
  46662. * @returns a serialized glow layer object
  46663. */
  46664. serialize(): any;
  46665. /**
  46666. * Creates a Glow Layer from parsed glow layer data
  46667. * @param parsedGlowLayer defines glow layer data
  46668. * @param scene defines the current scene
  46669. * @param rootUrl defines the root URL containing the glow layer information
  46670. * @returns a parsed Glow Layer
  46671. */
  46672. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  46673. }
  46674. }
  46675. declare module BABYLON {
  46676. /** @hidden */
  46677. export var glowBlurPostProcessPixelShader: {
  46678. name: string;
  46679. shader: string;
  46680. };
  46681. }
  46682. declare module BABYLON {
  46683. interface AbstractScene {
  46684. /**
  46685. * Return a the first highlight layer of the scene with a given name.
  46686. * @param name The name of the highlight layer to look for.
  46687. * @return The highlight layer if found otherwise null.
  46688. */
  46689. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  46690. }
  46691. /**
  46692. * Highlight layer options. This helps customizing the behaviour
  46693. * of the highlight layer.
  46694. */
  46695. export interface IHighlightLayerOptions {
  46696. /**
  46697. * Multiplication factor apply to the canvas size to compute the render target size
  46698. * used to generated the glowing objects (the smaller the faster).
  46699. */
  46700. mainTextureRatio: number;
  46701. /**
  46702. * Enforces a fixed size texture to ensure resize independant blur.
  46703. */
  46704. mainTextureFixedSize?: number;
  46705. /**
  46706. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  46707. * of the picture to blur (the smaller the faster).
  46708. */
  46709. blurTextureSizeRatio: number;
  46710. /**
  46711. * How big in texel of the blur texture is the vertical blur.
  46712. */
  46713. blurVerticalSize: number;
  46714. /**
  46715. * How big in texel of the blur texture is the horizontal blur.
  46716. */
  46717. blurHorizontalSize: number;
  46718. /**
  46719. * Alpha blending mode used to apply the blur. Default is combine.
  46720. */
  46721. alphaBlendingMode: number;
  46722. /**
  46723. * The camera attached to the layer.
  46724. */
  46725. camera: Nullable<Camera>;
  46726. /**
  46727. * Should we display highlight as a solid stroke?
  46728. */
  46729. isStroke?: boolean;
  46730. /**
  46731. * The rendering group to draw the layer in.
  46732. */
  46733. renderingGroupId: number;
  46734. }
  46735. /**
  46736. * The highlight layer Helps adding a glow effect around a mesh.
  46737. *
  46738. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  46739. * glowy meshes to your scene.
  46740. *
  46741. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  46742. */
  46743. export class HighlightLayer extends EffectLayer {
  46744. name: string;
  46745. /**
  46746. * Effect Name of the highlight layer.
  46747. */
  46748. static readonly EffectName: string;
  46749. /**
  46750. * The neutral color used during the preparation of the glow effect.
  46751. * This is black by default as the blend operation is a blend operation.
  46752. */
  46753. static NeutralColor: Color4;
  46754. /**
  46755. * Stencil value used for glowing meshes.
  46756. */
  46757. static GlowingMeshStencilReference: number;
  46758. /**
  46759. * Stencil value used for the other meshes in the scene.
  46760. */
  46761. static NormalMeshStencilReference: number;
  46762. /**
  46763. * Specifies whether or not the inner glow is ACTIVE in the layer.
  46764. */
  46765. innerGlow: boolean;
  46766. /**
  46767. * Specifies whether or not the outer glow is ACTIVE in the layer.
  46768. */
  46769. outerGlow: boolean;
  46770. /**
  46771. * Specifies the horizontal size of the blur.
  46772. */
  46773. /**
  46774. * Gets the horizontal size of the blur.
  46775. */
  46776. blurHorizontalSize: number;
  46777. /**
  46778. * Specifies the vertical size of the blur.
  46779. */
  46780. /**
  46781. * Gets the vertical size of the blur.
  46782. */
  46783. blurVerticalSize: number;
  46784. /**
  46785. * An event triggered when the highlight layer is being blurred.
  46786. */
  46787. onBeforeBlurObservable: Observable<HighlightLayer>;
  46788. /**
  46789. * An event triggered when the highlight layer has been blurred.
  46790. */
  46791. onAfterBlurObservable: Observable<HighlightLayer>;
  46792. private _instanceGlowingMeshStencilReference;
  46793. private _options;
  46794. private _downSamplePostprocess;
  46795. private _horizontalBlurPostprocess;
  46796. private _verticalBlurPostprocess;
  46797. private _blurTexture;
  46798. private _meshes;
  46799. private _excludedMeshes;
  46800. /**
  46801. * Instantiates a new highlight Layer and references it to the scene..
  46802. * @param name The name of the layer
  46803. * @param scene The scene to use the layer in
  46804. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  46805. */
  46806. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  46807. /**
  46808. * Get the effect name of the layer.
  46809. * @return The effect name
  46810. */
  46811. getEffectName(): string;
  46812. /**
  46813. * Create the merge effect. This is the shader use to blit the information back
  46814. * to the main canvas at the end of the scene rendering.
  46815. */
  46816. protected _createMergeEffect(): Effect;
  46817. /**
  46818. * Creates the render target textures and post processes used in the highlight layer.
  46819. */
  46820. protected _createTextureAndPostProcesses(): void;
  46821. /**
  46822. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  46823. */
  46824. needStencil(): boolean;
  46825. /**
  46826. * Checks for the readiness of the element composing the layer.
  46827. * @param subMesh the mesh to check for
  46828. * @param useInstances specify wether or not to use instances to render the mesh
  46829. * @param emissiveTexture the associated emissive texture used to generate the glow
  46830. * @return true if ready otherwise, false
  46831. */
  46832. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  46833. /**
  46834. * Implementation specific of rendering the generating effect on the main canvas.
  46835. * @param effect The effect used to render through
  46836. */
  46837. protected _internalRender(effect: Effect): void;
  46838. /**
  46839. * Returns true if the layer contains information to display, otherwise false.
  46840. */
  46841. shouldRender(): boolean;
  46842. /**
  46843. * Returns true if the mesh should render, otherwise false.
  46844. * @param mesh The mesh to render
  46845. * @returns true if it should render otherwise false
  46846. */
  46847. protected _shouldRenderMesh(mesh: Mesh): boolean;
  46848. /**
  46849. * Sets the required values for both the emissive texture and and the main color.
  46850. */
  46851. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  46852. /**
  46853. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  46854. * @param mesh The mesh to exclude from the highlight layer
  46855. */
  46856. addExcludedMesh(mesh: Mesh): void;
  46857. /**
  46858. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  46859. * @param mesh The mesh to highlight
  46860. */
  46861. removeExcludedMesh(mesh: Mesh): void;
  46862. /**
  46863. * Determine if a given mesh will be highlighted by the current HighlightLayer
  46864. * @param mesh mesh to test
  46865. * @returns true if the mesh will be highlighted by the current HighlightLayer
  46866. */
  46867. hasMesh(mesh: AbstractMesh): boolean;
  46868. /**
  46869. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  46870. * @param mesh The mesh to highlight
  46871. * @param color The color of the highlight
  46872. * @param glowEmissiveOnly Extract the glow from the emissive texture
  46873. */
  46874. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  46875. /**
  46876. * Remove a mesh from the highlight layer in order to make it stop glowing.
  46877. * @param mesh The mesh to highlight
  46878. */
  46879. removeMesh(mesh: Mesh): void;
  46880. /**
  46881. * Force the stencil to the normal expected value for none glowing parts
  46882. */
  46883. private _defaultStencilReference;
  46884. /**
  46885. * Free any resources and references associated to a mesh.
  46886. * Internal use
  46887. * @param mesh The mesh to free.
  46888. * @hidden
  46889. */ private _disposeMesh(mesh: Mesh): void;
  46890. /**
  46891. * Dispose the highlight layer and free resources.
  46892. */
  46893. dispose(): void;
  46894. /**
  46895. * Gets the class name of the effect layer
  46896. * @returns the string with the class name of the effect layer
  46897. */
  46898. getClassName(): string;
  46899. /**
  46900. * Serializes this Highlight layer
  46901. * @returns a serialized Highlight layer object
  46902. */
  46903. serialize(): any;
  46904. /**
  46905. * Creates a Highlight layer from parsed Highlight layer data
  46906. * @param parsedHightlightLayer defines the Highlight layer data
  46907. * @param scene defines the current scene
  46908. * @param rootUrl defines the root URL containing the Highlight layer information
  46909. * @returns a parsed Highlight layer
  46910. */
  46911. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  46912. }
  46913. }
  46914. declare module BABYLON {
  46915. interface AbstractScene {
  46916. /**
  46917. * The list of layers (background and foreground) of the scene
  46918. */
  46919. layers: Array<Layer>;
  46920. }
  46921. /**
  46922. * Defines the layer scene component responsible to manage any layers
  46923. * in a given scene.
  46924. */
  46925. export class LayerSceneComponent implements ISceneComponent {
  46926. /**
  46927. * The component name helpfull to identify the component in the list of scene components.
  46928. */
  46929. readonly name: string;
  46930. /**
  46931. * The scene the component belongs to.
  46932. */
  46933. scene: Scene;
  46934. private _engine;
  46935. /**
  46936. * Creates a new instance of the component for the given scene
  46937. * @param scene Defines the scene to register the component in
  46938. */
  46939. constructor(scene: Scene);
  46940. /**
  46941. * Registers the component in a given scene
  46942. */
  46943. register(): void;
  46944. /**
  46945. * Rebuilds the elements related to this component in case of
  46946. * context lost for instance.
  46947. */
  46948. rebuild(): void;
  46949. /**
  46950. * Disposes the component and the associated ressources.
  46951. */
  46952. dispose(): void;
  46953. private _draw;
  46954. private _drawCameraPredicate;
  46955. private _drawCameraBackground;
  46956. private _drawCameraForeground;
  46957. private _drawRenderTargetPredicate;
  46958. private _drawRenderTargetBackground;
  46959. private _drawRenderTargetForeground;
  46960. /**
  46961. * Adds all the elements from the container to the scene
  46962. * @param container the container holding the elements
  46963. */
  46964. addFromContainer(container: AbstractScene): void;
  46965. /**
  46966. * Removes all the elements in the container from the scene
  46967. * @param container contains the elements to remove
  46968. * @param dispose if the removed element should be disposed (default: false)
  46969. */
  46970. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  46971. }
  46972. }
  46973. declare module BABYLON {
  46974. /** @hidden */
  46975. export var layerPixelShader: {
  46976. name: string;
  46977. shader: string;
  46978. };
  46979. }
  46980. declare module BABYLON {
  46981. /** @hidden */
  46982. export var layerVertexShader: {
  46983. name: string;
  46984. shader: string;
  46985. };
  46986. }
  46987. declare module BABYLON {
  46988. /**
  46989. * This represents a full screen 2d layer.
  46990. * This can be useful to display a picture in the background of your scene for instance.
  46991. * @see https://www.babylonjs-playground.com/#08A2BS#1
  46992. */
  46993. export class Layer {
  46994. /**
  46995. * Define the name of the layer.
  46996. */
  46997. name: string;
  46998. /**
  46999. * Define the texture the layer should display.
  47000. */
  47001. texture: Nullable<Texture>;
  47002. /**
  47003. * Is the layer in background or foreground.
  47004. */
  47005. isBackground: boolean;
  47006. /**
  47007. * Define the color of the layer (instead of texture).
  47008. */
  47009. color: Color4;
  47010. /**
  47011. * Define the scale of the layer in order to zoom in out of the texture.
  47012. */
  47013. scale: Vector2;
  47014. /**
  47015. * Define an offset for the layer in order to shift the texture.
  47016. */
  47017. offset: Vector2;
  47018. /**
  47019. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  47020. */
  47021. alphaBlendingMode: number;
  47022. /**
  47023. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  47024. * Alpha test will not mix with the background color in case of transparency.
  47025. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  47026. */
  47027. alphaTest: boolean;
  47028. /**
  47029. * Define a mask to restrict the layer to only some of the scene cameras.
  47030. */
  47031. layerMask: number;
  47032. /**
  47033. * Define the list of render target the layer is visible into.
  47034. */
  47035. renderTargetTextures: RenderTargetTexture[];
  47036. /**
  47037. * Define if the layer is only used in renderTarget or if it also
  47038. * renders in the main frame buffer of the canvas.
  47039. */
  47040. renderOnlyInRenderTargetTextures: boolean;
  47041. private _scene;
  47042. private _vertexBuffers;
  47043. private _indexBuffer;
  47044. private _effect;
  47045. private _alphaTestEffect;
  47046. /**
  47047. * An event triggered when the layer is disposed.
  47048. */
  47049. onDisposeObservable: Observable<Layer>;
  47050. private _onDisposeObserver;
  47051. /**
  47052. * Back compatibility with callback before the onDisposeObservable existed.
  47053. * The set callback will be triggered when the layer has been disposed.
  47054. */
  47055. onDispose: () => void;
  47056. /**
  47057. * An event triggered before rendering the scene
  47058. */
  47059. onBeforeRenderObservable: Observable<Layer>;
  47060. private _onBeforeRenderObserver;
  47061. /**
  47062. * Back compatibility with callback before the onBeforeRenderObservable existed.
  47063. * The set callback will be triggered just before rendering the layer.
  47064. */
  47065. onBeforeRender: () => void;
  47066. /**
  47067. * An event triggered after rendering the scene
  47068. */
  47069. onAfterRenderObservable: Observable<Layer>;
  47070. private _onAfterRenderObserver;
  47071. /**
  47072. * Back compatibility with callback before the onAfterRenderObservable existed.
  47073. * The set callback will be triggered just after rendering the layer.
  47074. */
  47075. onAfterRender: () => void;
  47076. /**
  47077. * Instantiates a new layer.
  47078. * This represents a full screen 2d layer.
  47079. * This can be useful to display a picture in the background of your scene for instance.
  47080. * @see https://www.babylonjs-playground.com/#08A2BS#1
  47081. * @param name Define the name of the layer in the scene
  47082. * @param imgUrl Define the url of the texture to display in the layer
  47083. * @param scene Define the scene the layer belongs to
  47084. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  47085. * @param color Defines a color for the layer
  47086. */
  47087. constructor(
  47088. /**
  47089. * Define the name of the layer.
  47090. */
  47091. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  47092. private _createIndexBuffer;
  47093. /** @hidden */ private _rebuild(): void;
  47094. /**
  47095. * Renders the layer in the scene.
  47096. */
  47097. render(): void;
  47098. /**
  47099. * Disposes and releases the associated ressources.
  47100. */
  47101. dispose(): void;
  47102. }
  47103. }
  47104. declare module BABYLON {
  47105. /** @hidden */
  47106. export var lensFlarePixelShader: {
  47107. name: string;
  47108. shader: string;
  47109. };
  47110. }
  47111. declare module BABYLON {
  47112. /** @hidden */
  47113. export var lensFlareVertexShader: {
  47114. name: string;
  47115. shader: string;
  47116. };
  47117. }
  47118. declare module BABYLON {
  47119. /**
  47120. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47121. * It is usually composed of several `lensFlare`.
  47122. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47123. */
  47124. export class LensFlareSystem {
  47125. /**
  47126. * Define the name of the lens flare system
  47127. */
  47128. name: string;
  47129. /**
  47130. * List of lens flares used in this system.
  47131. */
  47132. lensFlares: LensFlare[];
  47133. /**
  47134. * Define a limit from the border the lens flare can be visible.
  47135. */
  47136. borderLimit: number;
  47137. /**
  47138. * Define a viewport border we do not want to see the lens flare in.
  47139. */
  47140. viewportBorder: number;
  47141. /**
  47142. * Define a predicate which could limit the list of meshes able to occlude the effect.
  47143. */
  47144. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47145. /**
  47146. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  47147. */
  47148. layerMask: number;
  47149. /**
  47150. * Define the id of the lens flare system in the scene.
  47151. * (equal to name by default)
  47152. */
  47153. id: string;
  47154. private _scene;
  47155. private _emitter;
  47156. private _vertexBuffers;
  47157. private _indexBuffer;
  47158. private _effect;
  47159. private _positionX;
  47160. private _positionY;
  47161. private _isEnabled;
  47162. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47163. /**
  47164. * Instantiates a lens flare system.
  47165. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  47166. * It is usually composed of several `lensFlare`.
  47167. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47168. * @param name Define the name of the lens flare system in the scene
  47169. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  47170. * @param scene Define the scene the lens flare system belongs to
  47171. */
  47172. constructor(
  47173. /**
  47174. * Define the name of the lens flare system
  47175. */
  47176. name: string, emitter: any, scene: Scene);
  47177. /**
  47178. * Define if the lens flare system is enabled.
  47179. */
  47180. isEnabled: boolean;
  47181. /**
  47182. * Get the scene the effects belongs to.
  47183. * @returns the scene holding the lens flare system
  47184. */
  47185. getScene(): Scene;
  47186. /**
  47187. * Get the emitter of the lens flare system.
  47188. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47189. * @returns the emitter of the lens flare system
  47190. */
  47191. getEmitter(): any;
  47192. /**
  47193. * Set the emitter of the lens flare system.
  47194. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  47195. * @param newEmitter Define the new emitter of the system
  47196. */
  47197. setEmitter(newEmitter: any): void;
  47198. /**
  47199. * Get the lens flare system emitter position.
  47200. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  47201. * @returns the position
  47202. */
  47203. getEmitterPosition(): Vector3;
  47204. /**
  47205. * @hidden
  47206. */
  47207. computeEffectivePosition(globalViewport: Viewport): boolean;
  47208. /** @hidden */ private _isVisible(): boolean;
  47209. /**
  47210. * @hidden
  47211. */
  47212. render(): boolean;
  47213. /**
  47214. * Dispose and release the lens flare with its associated resources.
  47215. */
  47216. dispose(): void;
  47217. /**
  47218. * Parse a lens flare system from a JSON repressentation
  47219. * @param parsedLensFlareSystem Define the JSON to parse
  47220. * @param scene Define the scene the parsed system should be instantiated in
  47221. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  47222. * @returns the parsed system
  47223. */
  47224. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  47225. /**
  47226. * Serialize the current Lens Flare System into a JSON representation.
  47227. * @returns the serialized JSON
  47228. */
  47229. serialize(): any;
  47230. }
  47231. }
  47232. declare module BABYLON {
  47233. /**
  47234. * This represents one of the lens effect in a `lensFlareSystem`.
  47235. * It controls one of the indiviual texture used in the effect.
  47236. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47237. */
  47238. export class LensFlare {
  47239. /**
  47240. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47241. */
  47242. size: number;
  47243. /**
  47244. * 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.
  47245. */
  47246. position: number;
  47247. /**
  47248. * Define the lens color.
  47249. */
  47250. color: Color3;
  47251. /**
  47252. * Define the lens texture.
  47253. */
  47254. texture: Nullable<Texture>;
  47255. /**
  47256. * Define the alpha mode to render this particular lens.
  47257. */
  47258. alphaMode: number;
  47259. private _system;
  47260. /**
  47261. * Creates a new Lens Flare.
  47262. * This represents one of the lens effect in a `lensFlareSystem`.
  47263. * It controls one of the indiviual texture used in the effect.
  47264. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47265. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  47266. * @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.
  47267. * @param color Define the lens color
  47268. * @param imgUrl Define the lens texture url
  47269. * @param system Define the `lensFlareSystem` this flare is part of
  47270. * @returns The newly created Lens Flare
  47271. */
  47272. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  47273. /**
  47274. * Instantiates a new Lens Flare.
  47275. * This represents one of the lens effect in a `lensFlareSystem`.
  47276. * It controls one of the indiviual texture used in the effect.
  47277. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47278. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  47279. * @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.
  47280. * @param color Define the lens color
  47281. * @param imgUrl Define the lens texture url
  47282. * @param system Define the `lensFlareSystem` this flare is part of
  47283. */
  47284. constructor(
  47285. /**
  47286. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  47287. */
  47288. size: number,
  47289. /**
  47290. * 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.
  47291. */
  47292. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  47293. /**
  47294. * Dispose and release the lens flare with its associated resources.
  47295. */
  47296. dispose(): void;
  47297. }
  47298. }
  47299. declare module BABYLON {
  47300. interface AbstractScene {
  47301. /**
  47302. * The list of lens flare system added to the scene
  47303. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  47304. */
  47305. lensFlareSystems: Array<LensFlareSystem>;
  47306. /**
  47307. * Removes the given lens flare system from this scene.
  47308. * @param toRemove The lens flare system to remove
  47309. * @returns The index of the removed lens flare system
  47310. */
  47311. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  47312. /**
  47313. * Adds the given lens flare system to this scene
  47314. * @param newLensFlareSystem The lens flare system to add
  47315. */
  47316. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  47317. /**
  47318. * Gets a lens flare system using its name
  47319. * @param name defines the name to look for
  47320. * @returns the lens flare system or null if not found
  47321. */
  47322. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  47323. /**
  47324. * Gets a lens flare system using its id
  47325. * @param id defines the id to look for
  47326. * @returns the lens flare system or null if not found
  47327. */
  47328. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  47329. }
  47330. /**
  47331. * Defines the lens flare scene component responsible to manage any lens flares
  47332. * in a given scene.
  47333. */
  47334. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  47335. /**
  47336. * The component name helpfull to identify the component in the list of scene components.
  47337. */
  47338. readonly name: string;
  47339. /**
  47340. * The scene the component belongs to.
  47341. */
  47342. scene: Scene;
  47343. /**
  47344. * Creates a new instance of the component for the given scene
  47345. * @param scene Defines the scene to register the component in
  47346. */
  47347. constructor(scene: Scene);
  47348. /**
  47349. * Registers the component in a given scene
  47350. */
  47351. register(): void;
  47352. /**
  47353. * Rebuilds the elements related to this component in case of
  47354. * context lost for instance.
  47355. */
  47356. rebuild(): void;
  47357. /**
  47358. * Adds all the elements from the container to the scene
  47359. * @param container the container holding the elements
  47360. */
  47361. addFromContainer(container: AbstractScene): void;
  47362. /**
  47363. * Removes all the elements in the container from the scene
  47364. * @param container contains the elements to remove
  47365. * @param dispose if the removed element should be disposed (default: false)
  47366. */
  47367. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47368. /**
  47369. * Serializes the component data to the specified json object
  47370. * @param serializationObject The object to serialize to
  47371. */
  47372. serialize(serializationObject: any): void;
  47373. /**
  47374. * Disposes the component and the associated ressources.
  47375. */
  47376. dispose(): void;
  47377. private _draw;
  47378. }
  47379. }
  47380. declare module BABYLON {
  47381. /**
  47382. * Defines the shadow generator component responsible to manage any shadow generators
  47383. * in a given scene.
  47384. */
  47385. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  47386. /**
  47387. * The component name helpfull to identify the component in the list of scene components.
  47388. */
  47389. readonly name: string;
  47390. /**
  47391. * The scene the component belongs to.
  47392. */
  47393. scene: Scene;
  47394. /**
  47395. * Creates a new instance of the component for the given scene
  47396. * @param scene Defines the scene to register the component in
  47397. */
  47398. constructor(scene: Scene);
  47399. /**
  47400. * Registers the component in a given scene
  47401. */
  47402. register(): void;
  47403. /**
  47404. * Rebuilds the elements related to this component in case of
  47405. * context lost for instance.
  47406. */
  47407. rebuild(): void;
  47408. /**
  47409. * Serializes the component data to the specified json object
  47410. * @param serializationObject The object to serialize to
  47411. */
  47412. serialize(serializationObject: any): void;
  47413. /**
  47414. * Adds all the elements from the container to the scene
  47415. * @param container the container holding the elements
  47416. */
  47417. addFromContainer(container: AbstractScene): void;
  47418. /**
  47419. * Removes all the elements in the container from the scene
  47420. * @param container contains the elements to remove
  47421. * @param dispose if the removed element should be disposed (default: false)
  47422. */
  47423. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47424. /**
  47425. * Rebuilds the elements related to this component in case of
  47426. * context lost for instance.
  47427. */
  47428. dispose(): void;
  47429. private _gatherRenderTargets;
  47430. }
  47431. }
  47432. declare module BABYLON {
  47433. /**
  47434. * A point light is a light defined by an unique point in world space.
  47435. * The light is emitted in every direction from this point.
  47436. * A good example of a point light is a standard light bulb.
  47437. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47438. */
  47439. export class PointLight extends ShadowLight {
  47440. private _shadowAngle;
  47441. /**
  47442. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47443. * This specifies what angle the shadow will use to be created.
  47444. *
  47445. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47446. */
  47447. /**
  47448. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47449. * This specifies what angle the shadow will use to be created.
  47450. *
  47451. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  47452. */
  47453. shadowAngle: number;
  47454. /**
  47455. * Gets the direction if it has been set.
  47456. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47457. */
  47458. /**
  47459. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  47460. */
  47461. direction: Vector3;
  47462. /**
  47463. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  47464. * A PointLight emits the light in every direction.
  47465. * It can cast shadows.
  47466. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  47467. * ```javascript
  47468. * var pointLight = new PointLight("pl", camera.position, scene);
  47469. * ```
  47470. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47471. * @param name The light friendly name
  47472. * @param position The position of the point light in the scene
  47473. * @param scene The scene the lights belongs to
  47474. */
  47475. constructor(name: string, position: Vector3, scene: Scene);
  47476. /**
  47477. * Returns the string "PointLight"
  47478. * @returns the class name
  47479. */
  47480. getClassName(): string;
  47481. /**
  47482. * Returns the integer 0.
  47483. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47484. */
  47485. getTypeID(): number;
  47486. /**
  47487. * Specifies wether or not the shadowmap should be a cube texture.
  47488. * @returns true if the shadowmap needs to be a cube texture.
  47489. */
  47490. needCube(): boolean;
  47491. /**
  47492. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47493. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47494. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47495. */
  47496. getShadowDirection(faceIndex?: number): Vector3;
  47497. /**
  47498. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47499. * - fov = PI / 2
  47500. * - aspect ratio : 1.0
  47501. * - z-near and far equal to the active camera minZ and maxZ.
  47502. * Returns the PointLight.
  47503. */
  47504. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47505. protected _buildUniformLayout(): void;
  47506. /**
  47507. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47508. * @param effect The effect to update
  47509. * @param lightIndex The index of the light in the effect to update
  47510. * @returns The point light
  47511. */
  47512. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  47513. /**
  47514. * Prepares the list of defines specific to the light type.
  47515. * @param defines the list of defines
  47516. * @param lightIndex defines the index of the light for the effect
  47517. */
  47518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47519. }
  47520. }
  47521. declare module BABYLON {
  47522. /**
  47523. * Header information of HDR texture files.
  47524. */
  47525. export interface HDRInfo {
  47526. /**
  47527. * The height of the texture in pixels.
  47528. */
  47529. height: number;
  47530. /**
  47531. * The width of the texture in pixels.
  47532. */
  47533. width: number;
  47534. /**
  47535. * The index of the beginning of the data in the binary file.
  47536. */
  47537. dataPosition: number;
  47538. }
  47539. /**
  47540. * This groups tools to convert HDR texture to native colors array.
  47541. */
  47542. export class HDRTools {
  47543. private static Ldexp;
  47544. private static Rgbe2float;
  47545. private static readStringLine;
  47546. /**
  47547. * Reads header information from an RGBE texture stored in a native array.
  47548. * More information on this format are available here:
  47549. * https://en.wikipedia.org/wiki/RGBE_image_format
  47550. *
  47551. * @param uint8array The binary file stored in native array.
  47552. * @return The header information.
  47553. */
  47554. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  47555. /**
  47556. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  47557. * This RGBE texture needs to store the information as a panorama.
  47558. *
  47559. * More information on this format are available here:
  47560. * https://en.wikipedia.org/wiki/RGBE_image_format
  47561. *
  47562. * @param buffer The binary file stored in an array buffer.
  47563. * @param size The expected size of the extracted cubemap.
  47564. * @return The Cube Map information.
  47565. */
  47566. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  47567. /**
  47568. * Returns the pixels data extracted from an RGBE texture.
  47569. * This pixels will be stored left to right up to down in the R G B order in one array.
  47570. *
  47571. * More information on this format are available here:
  47572. * https://en.wikipedia.org/wiki/RGBE_image_format
  47573. *
  47574. * @param uint8array The binary file stored in an array buffer.
  47575. * @param hdrInfo The header information of the file.
  47576. * @return The pixels data in RGB right to left up to down order.
  47577. */
  47578. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  47579. private static RGBE_ReadPixels_RLE;
  47580. }
  47581. }
  47582. declare module BABYLON {
  47583. /**
  47584. * This represents a texture coming from an HDR input.
  47585. *
  47586. * The only supported format is currently panorama picture stored in RGBE format.
  47587. * Example of such files can be found on HDRLib: http://hdrlib.com/
  47588. */
  47589. export class HDRCubeTexture extends BaseTexture {
  47590. private static _facesMapping;
  47591. private _generateHarmonics;
  47592. private _noMipmap;
  47593. private _textureMatrix;
  47594. private _size;
  47595. private _onLoad;
  47596. private _onError;
  47597. /**
  47598. * The texture URL.
  47599. */
  47600. url: string;
  47601. /**
  47602. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  47603. */
  47604. coordinatesMode: number;
  47605. protected _isBlocking: boolean;
  47606. /**
  47607. * Sets wether or not the texture is blocking during loading.
  47608. */
  47609. /**
  47610. * Gets wether or not the texture is blocking during loading.
  47611. */
  47612. isBlocking: boolean;
  47613. protected _rotationY: number;
  47614. /**
  47615. * Sets texture matrix rotation angle around Y axis in radians.
  47616. */
  47617. /**
  47618. * Gets texture matrix rotation angle around Y axis radians.
  47619. */
  47620. rotationY: number;
  47621. /**
  47622. * Gets or sets the center of the bounding box associated with the cube texture
  47623. * It must define where the camera used to render the texture was set
  47624. */
  47625. boundingBoxPosition: Vector3;
  47626. private _boundingBoxSize;
  47627. /**
  47628. * Gets or sets the size of the bounding box associated with the cube texture
  47629. * When defined, the cubemap will switch to local mode
  47630. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  47631. * @example https://www.babylonjs-playground.com/#RNASML
  47632. */
  47633. boundingBoxSize: Vector3;
  47634. /**
  47635. * Instantiates an HDRTexture from the following parameters.
  47636. *
  47637. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  47638. * @param scene The scene the texture will be used in
  47639. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  47640. * @param noMipmap Forces to not generate the mipmap if true
  47641. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  47642. * @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)
  47643. * @param reserved Reserved flag for internal use.
  47644. */
  47645. 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>);
  47646. /**
  47647. * Get the current class name of the texture useful for serialization or dynamic coding.
  47648. * @returns "HDRCubeTexture"
  47649. */
  47650. getClassName(): string;
  47651. /**
  47652. * Occurs when the file is raw .hdr file.
  47653. */
  47654. private loadTexture;
  47655. clone(): HDRCubeTexture;
  47656. delayLoad(): void;
  47657. /**
  47658. * Get the texture reflection matrix used to rotate/transform the reflection.
  47659. * @returns the reflection matrix
  47660. */
  47661. getReflectionTextureMatrix(): Matrix;
  47662. /**
  47663. * Set the texture reflection matrix used to rotate/transform the reflection.
  47664. * @param value Define the reflection matrix to set
  47665. */
  47666. setReflectionTextureMatrix(value: Matrix): void;
  47667. /**
  47668. * Parses a JSON representation of an HDR Texture in order to create the texture
  47669. * @param parsedTexture Define the JSON representation
  47670. * @param scene Define the scene the texture should be created in
  47671. * @param rootUrl Define the root url in case we need to load relative dependencies
  47672. * @returns the newly created texture after parsing
  47673. */
  47674. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  47675. serialize(): any;
  47676. }
  47677. }
  47678. declare module BABYLON {
  47679. /**
  47680. * Class used to control physics engine
  47681. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  47682. */
  47683. export class PhysicsEngine implements IPhysicsEngine {
  47684. private _physicsPlugin;
  47685. /**
  47686. * Global value used to control the smallest number supported by the simulation
  47687. */
  47688. static Epsilon: number;
  47689. private _impostors;
  47690. private _joints;
  47691. /**
  47692. * Gets the gravity vector used by the simulation
  47693. */
  47694. gravity: Vector3;
  47695. /**
  47696. * Factory used to create the default physics plugin.
  47697. * @returns The default physics plugin
  47698. */
  47699. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  47700. /**
  47701. * Creates a new Physics Engine
  47702. * @param gravity defines the gravity vector used by the simulation
  47703. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  47704. */
  47705. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  47706. /**
  47707. * Sets the gravity vector used by the simulation
  47708. * @param gravity defines the gravity vector to use
  47709. */
  47710. setGravity(gravity: Vector3): void;
  47711. /**
  47712. * Set the time step of the physics engine.
  47713. * Default is 1/60.
  47714. * To slow it down, enter 1/600 for example.
  47715. * To speed it up, 1/30
  47716. * @param newTimeStep defines the new timestep to apply to this world.
  47717. */
  47718. setTimeStep(newTimeStep?: number): void;
  47719. /**
  47720. * Get the time step of the physics engine.
  47721. * @returns the current time step
  47722. */
  47723. getTimeStep(): number;
  47724. /**
  47725. * Release all resources
  47726. */
  47727. dispose(): void;
  47728. /**
  47729. * Gets the name of the current physics plugin
  47730. * @returns the name of the plugin
  47731. */
  47732. getPhysicsPluginName(): string;
  47733. /**
  47734. * Adding a new impostor for the impostor tracking.
  47735. * This will be done by the impostor itself.
  47736. * @param impostor the impostor to add
  47737. */
  47738. addImpostor(impostor: PhysicsImpostor): void;
  47739. /**
  47740. * Remove an impostor from the engine.
  47741. * This impostor and its mesh will not longer be updated by the physics engine.
  47742. * @param impostor the impostor to remove
  47743. */
  47744. removeImpostor(impostor: PhysicsImpostor): void;
  47745. /**
  47746. * Add a joint to the physics engine
  47747. * @param mainImpostor defines the main impostor to which the joint is added.
  47748. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  47749. * @param joint defines the joint that will connect both impostors.
  47750. */
  47751. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47752. /**
  47753. * Removes a joint from the simulation
  47754. * @param mainImpostor defines the impostor used with the joint
  47755. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  47756. * @param joint defines the joint to remove
  47757. */
  47758. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  47759. /**
  47760. * Called by the scene. No need to call it.
  47761. * @param delta defines the timespam between frames
  47762. */ private _step(delta: number): void;
  47763. /**
  47764. * Gets the current plugin used to run the simulation
  47765. * @returns current plugin
  47766. */
  47767. getPhysicsPlugin(): IPhysicsEnginePlugin;
  47768. /**
  47769. * Gets the list of physic impostors
  47770. * @returns an array of PhysicsImpostor
  47771. */
  47772. getImpostors(): Array<PhysicsImpostor>;
  47773. /**
  47774. * Gets the impostor for a physics enabled object
  47775. * @param object defines the object impersonated by the impostor
  47776. * @returns the PhysicsImpostor or null if not found
  47777. */
  47778. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  47779. /**
  47780. * Gets the impostor for a physics body object
  47781. * @param body defines physics body used by the impostor
  47782. * @returns the PhysicsImpostor or null if not found
  47783. */
  47784. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  47785. /**
  47786. * Does a raycast in the physics world
  47787. * @param from when should the ray start?
  47788. * @param to when should the ray end?
  47789. * @returns PhysicsRaycastResult
  47790. */
  47791. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47792. }
  47793. }
  47794. declare module BABYLON {
  47795. /** @hidden */
  47796. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  47797. private _useDeltaForWorldStep;
  47798. world: any;
  47799. name: string;
  47800. private _physicsMaterials;
  47801. private _fixedTimeStep;
  47802. private _cannonRaycastResult;
  47803. private _raycastResult;
  47804. private _removeAfterStep;
  47805. BJSCANNON: any;
  47806. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  47807. setGravity(gravity: Vector3): void;
  47808. setTimeStep(timeStep: number): void;
  47809. getTimeStep(): number;
  47810. executeStep(delta: number): void;
  47811. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47812. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47813. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47814. private _processChildMeshes;
  47815. removePhysicsBody(impostor: PhysicsImpostor): void;
  47816. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47817. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47818. private _addMaterial;
  47819. private _checkWithEpsilon;
  47820. private _createShape;
  47821. private _createHeightmap;
  47822. private _minus90X;
  47823. private _plus90X;
  47824. private _tmpPosition;
  47825. private _tmpDeltaPosition;
  47826. private _tmpUnityRotation;
  47827. private _updatePhysicsBodyTransformation;
  47828. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47829. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47830. isSupported(): boolean;
  47831. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47832. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47833. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47834. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47835. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47836. getBodyMass(impostor: PhysicsImpostor): number;
  47837. getBodyFriction(impostor: PhysicsImpostor): number;
  47838. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47839. getBodyRestitution(impostor: PhysicsImpostor): number;
  47840. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47841. sleepBody(impostor: PhysicsImpostor): void;
  47842. wakeUpBody(impostor: PhysicsImpostor): void;
  47843. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  47844. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  47845. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  47846. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47847. getRadius(impostor: PhysicsImpostor): number;
  47848. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47849. dispose(): void;
  47850. private _extendNamespace;
  47851. /**
  47852. * Does a raycast in the physics world
  47853. * @param from when should the ray start?
  47854. * @param to when should the ray end?
  47855. * @returns PhysicsRaycastResult
  47856. */
  47857. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47858. }
  47859. }
  47860. declare module BABYLON {
  47861. /** @hidden */
  47862. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  47863. world: any;
  47864. name: string;
  47865. BJSOIMO: any;
  47866. private _raycastResult;
  47867. constructor(iterations?: number, oimoInjection?: any);
  47868. setGravity(gravity: Vector3): void;
  47869. setTimeStep(timeStep: number): void;
  47870. getTimeStep(): number;
  47871. private _tmpImpostorsArray;
  47872. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  47873. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47874. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  47875. generatePhysicsBody(impostor: PhysicsImpostor): void;
  47876. private _tmpPositionVector;
  47877. removePhysicsBody(impostor: PhysicsImpostor): void;
  47878. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  47879. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  47880. isSupported(): boolean;
  47881. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  47882. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  47883. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47884. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  47885. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47886. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  47887. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  47888. getBodyMass(impostor: PhysicsImpostor): number;
  47889. getBodyFriction(impostor: PhysicsImpostor): number;
  47890. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  47891. getBodyRestitution(impostor: PhysicsImpostor): number;
  47892. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  47893. sleepBody(impostor: PhysicsImpostor): void;
  47894. wakeUpBody(impostor: PhysicsImpostor): void;
  47895. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  47896. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  47897. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  47898. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  47899. getRadius(impostor: PhysicsImpostor): number;
  47900. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  47901. dispose(): void;
  47902. /**
  47903. * Does a raycast in the physics world
  47904. * @param from when should the ray start?
  47905. * @param to when should the ray end?
  47906. * @returns PhysicsRaycastResult
  47907. */
  47908. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  47909. }
  47910. }
  47911. declare module BABYLON {
  47912. /**
  47913. * Class containing static functions to help procedurally build meshes
  47914. */
  47915. export class RibbonBuilder {
  47916. /**
  47917. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  47918. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  47919. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  47920. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  47921. * * 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
  47922. * * 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
  47923. * * 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
  47924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  47927. * * 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
  47928. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  47929. * * 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
  47930. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  47931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47932. * @param name defines the name of the mesh
  47933. * @param options defines the options used to create the mesh
  47934. * @param scene defines the hosting scene
  47935. * @returns the ribbon mesh
  47936. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  47937. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47938. */
  47939. static CreateRibbon(name: string, options: {
  47940. pathArray: Vector3[][];
  47941. closeArray?: boolean;
  47942. closePath?: boolean;
  47943. offset?: number;
  47944. updatable?: boolean;
  47945. sideOrientation?: number;
  47946. frontUVs?: Vector4;
  47947. backUVs?: Vector4;
  47948. instance?: Mesh;
  47949. invertUV?: boolean;
  47950. uvs?: Vector2[];
  47951. colors?: Color4[];
  47952. }, scene?: Nullable<Scene>): Mesh;
  47953. }
  47954. }
  47955. declare module BABYLON {
  47956. /**
  47957. * Class containing static functions to help procedurally build meshes
  47958. */
  47959. export class ShapeBuilder {
  47960. /**
  47961. * 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.
  47962. * * 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.
  47963. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47964. * * 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.
  47965. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  47966. * * 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
  47967. * * 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
  47968. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  47969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47971. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  47972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47973. * @param name defines the name of the mesh
  47974. * @param options defines the options used to create the mesh
  47975. * @param scene defines the hosting scene
  47976. * @returns the extruded shape mesh
  47977. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  47978. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  47979. */
  47980. static ExtrudeShape(name: string, options: {
  47981. shape: Vector3[];
  47982. path: Vector3[];
  47983. scale?: number;
  47984. rotation?: number;
  47985. cap?: number;
  47986. updatable?: boolean;
  47987. sideOrientation?: number;
  47988. frontUVs?: Vector4;
  47989. backUVs?: Vector4;
  47990. instance?: Mesh;
  47991. invertUV?: boolean;
  47992. }, scene?: Nullable<Scene>): Mesh;
  47993. /**
  47994. * Creates an custom extruded shape mesh.
  47995. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  47996. * * 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.
  47997. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  47998. * * 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
  47999. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  48000. * * 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
  48001. * * It must returns a float value that will be the scale value applied to the shape on each path point
  48002. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  48003. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  48004. * * 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
  48005. * * 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
  48006. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  48007. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48008. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48009. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  48010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48011. * @param name defines the name of the mesh
  48012. * @param options defines the options used to create the mesh
  48013. * @param scene defines the hosting scene
  48014. * @returns the custom extruded shape mesh
  48015. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  48016. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  48017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  48018. */
  48019. static ExtrudeShapeCustom(name: string, options: {
  48020. shape: Vector3[];
  48021. path: Vector3[];
  48022. scaleFunction?: any;
  48023. rotationFunction?: any;
  48024. ribbonCloseArray?: boolean;
  48025. ribbonClosePath?: boolean;
  48026. cap?: number;
  48027. updatable?: boolean;
  48028. sideOrientation?: number;
  48029. frontUVs?: Vector4;
  48030. backUVs?: Vector4;
  48031. instance?: Mesh;
  48032. invertUV?: boolean;
  48033. }, scene?: Nullable<Scene>): Mesh;
  48034. private static _ExtrudeShapeGeneric;
  48035. }
  48036. }
  48037. declare module BABYLON {
  48038. /**
  48039. * AmmoJS Physics plugin
  48040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  48041. * @see https://github.com/kripken/ammo.js/
  48042. */
  48043. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  48044. private _useDeltaForWorldStep;
  48045. /**
  48046. * Reference to the Ammo library
  48047. */
  48048. bjsAMMO: any;
  48049. /**
  48050. * Created ammoJS world which physics bodies are added to
  48051. */
  48052. world: any;
  48053. /**
  48054. * Name of the plugin
  48055. */
  48056. name: string;
  48057. private _timeStep;
  48058. private _fixedTimeStep;
  48059. private _maxSteps;
  48060. private _tmpQuaternion;
  48061. private _tmpAmmoTransform;
  48062. private _tmpAmmoQuaternion;
  48063. private _tmpAmmoConcreteContactResultCallback;
  48064. private _collisionConfiguration;
  48065. private _dispatcher;
  48066. private _overlappingPairCache;
  48067. private _solver;
  48068. private _softBodySolver;
  48069. private _tmpAmmoVectorA;
  48070. private _tmpAmmoVectorB;
  48071. private _tmpAmmoVectorC;
  48072. private _tmpAmmoVectorD;
  48073. private _tmpContactCallbackResult;
  48074. private _tmpAmmoVectorRCA;
  48075. private _tmpAmmoVectorRCB;
  48076. private _raycastResult;
  48077. private static readonly DISABLE_COLLISION_FLAG;
  48078. private static readonly KINEMATIC_FLAG;
  48079. private static readonly DISABLE_DEACTIVATION_FLAG;
  48080. /**
  48081. * Initializes the ammoJS plugin
  48082. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  48083. * @param ammoInjection can be used to inject your own ammo reference
  48084. */
  48085. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  48086. /**
  48087. * Sets the gravity of the physics world (m/(s^2))
  48088. * @param gravity Gravity to set
  48089. */
  48090. setGravity(gravity: Vector3): void;
  48091. /**
  48092. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  48093. * @param timeStep timestep to use in seconds
  48094. */
  48095. setTimeStep(timeStep: number): void;
  48096. /**
  48097. * 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)
  48098. * @param fixedTimeStep fixedTimeStep to use in seconds
  48099. */
  48100. setFixedTimeStep(fixedTimeStep: number): void;
  48101. /**
  48102. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  48103. * @param maxSteps the maximum number of steps by the physics engine per frame
  48104. */
  48105. setMaxSteps(maxSteps: number): void;
  48106. /**
  48107. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  48108. * @returns the current timestep in seconds
  48109. */
  48110. getTimeStep(): number;
  48111. private _isImpostorInContact;
  48112. private _isImpostorPairInContact;
  48113. private _stepSimulation;
  48114. /**
  48115. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  48116. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  48117. * After the step the babylon meshes are set to the position of the physics imposters
  48118. * @param delta amount of time to step forward
  48119. * @param impostors array of imposters to update before/after the step
  48120. */
  48121. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  48122. /**
  48123. * Update babylon mesh to match physics world object
  48124. * @param impostor imposter to match
  48125. */
  48126. private _afterSoftStep;
  48127. /**
  48128. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48129. * @param impostor imposter to match
  48130. */
  48131. private _ropeStep;
  48132. /**
  48133. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  48134. * @param impostor imposter to match
  48135. */
  48136. private _softbodyOrClothStep;
  48137. private _tmpVector;
  48138. private _tmpMatrix;
  48139. /**
  48140. * Applies an impulse on the imposter
  48141. * @param impostor imposter to apply impulse to
  48142. * @param force amount of force to be applied to the imposter
  48143. * @param contactPoint the location to apply the impulse on the imposter
  48144. */
  48145. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48146. /**
  48147. * Applies a force on the imposter
  48148. * @param impostor imposter to apply force
  48149. * @param force amount of force to be applied to the imposter
  48150. * @param contactPoint the location to apply the force on the imposter
  48151. */
  48152. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  48153. /**
  48154. * Creates a physics body using the plugin
  48155. * @param impostor the imposter to create the physics body on
  48156. */
  48157. generatePhysicsBody(impostor: PhysicsImpostor): void;
  48158. /**
  48159. * Removes the physics body from the imposter and disposes of the body's memory
  48160. * @param impostor imposter to remove the physics body from
  48161. */
  48162. removePhysicsBody(impostor: PhysicsImpostor): void;
  48163. /**
  48164. * Generates a joint
  48165. * @param impostorJoint the imposter joint to create the joint with
  48166. */
  48167. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  48168. /**
  48169. * Removes a joint
  48170. * @param impostorJoint the imposter joint to remove the joint from
  48171. */
  48172. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  48173. private _addMeshVerts;
  48174. /**
  48175. * Initialise the soft body vertices to match its object's (mesh) vertices
  48176. * Softbody vertices (nodes) are in world space and to match this
  48177. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  48178. * @param impostor to create the softbody for
  48179. */
  48180. private _softVertexData;
  48181. /**
  48182. * Create an impostor's soft body
  48183. * @param impostor to create the softbody for
  48184. */
  48185. private _createSoftbody;
  48186. /**
  48187. * Create cloth for an impostor
  48188. * @param impostor to create the softbody for
  48189. */
  48190. private _createCloth;
  48191. /**
  48192. * Create rope for an impostor
  48193. * @param impostor to create the softbody for
  48194. */
  48195. private _createRope;
  48196. private _addHullVerts;
  48197. private _createShape;
  48198. /**
  48199. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  48200. * @param impostor imposter containing the physics body and babylon object
  48201. */
  48202. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  48203. /**
  48204. * Sets the babylon object's position/rotation from the physics body's position/rotation
  48205. * @param impostor imposter containing the physics body and babylon object
  48206. * @param newPosition new position
  48207. * @param newRotation new rotation
  48208. */
  48209. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  48210. /**
  48211. * If this plugin is supported
  48212. * @returns true if its supported
  48213. */
  48214. isSupported(): boolean;
  48215. /**
  48216. * Sets the linear velocity of the physics body
  48217. * @param impostor imposter to set the velocity on
  48218. * @param velocity velocity to set
  48219. */
  48220. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48221. /**
  48222. * Sets the angular velocity of the physics body
  48223. * @param impostor imposter to set the velocity on
  48224. * @param velocity velocity to set
  48225. */
  48226. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  48227. /**
  48228. * gets the linear velocity
  48229. * @param impostor imposter to get linear velocity from
  48230. * @returns linear velocity
  48231. */
  48232. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48233. /**
  48234. * gets the angular velocity
  48235. * @param impostor imposter to get angular velocity from
  48236. * @returns angular velocity
  48237. */
  48238. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  48239. /**
  48240. * Sets the mass of physics body
  48241. * @param impostor imposter to set the mass on
  48242. * @param mass mass to set
  48243. */
  48244. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  48245. /**
  48246. * Gets the mass of the physics body
  48247. * @param impostor imposter to get the mass from
  48248. * @returns mass
  48249. */
  48250. getBodyMass(impostor: PhysicsImpostor): number;
  48251. /**
  48252. * Gets friction of the impostor
  48253. * @param impostor impostor to get friction from
  48254. * @returns friction value
  48255. */
  48256. getBodyFriction(impostor: PhysicsImpostor): number;
  48257. /**
  48258. * Sets friction of the impostor
  48259. * @param impostor impostor to set friction on
  48260. * @param friction friction value
  48261. */
  48262. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  48263. /**
  48264. * Gets restitution of the impostor
  48265. * @param impostor impostor to get restitution from
  48266. * @returns restitution value
  48267. */
  48268. getBodyRestitution(impostor: PhysicsImpostor): number;
  48269. /**
  48270. * Sets resitution of the impostor
  48271. * @param impostor impostor to set resitution on
  48272. * @param restitution resitution value
  48273. */
  48274. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  48275. /**
  48276. * Gets pressure inside the impostor
  48277. * @param impostor impostor to get pressure from
  48278. * @returns pressure value
  48279. */
  48280. getBodyPressure(impostor: PhysicsImpostor): number;
  48281. /**
  48282. * Sets pressure inside a soft body impostor
  48283. * Cloth and rope must remain 0 pressure
  48284. * @param impostor impostor to set pressure on
  48285. * @param pressure pressure value
  48286. */
  48287. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  48288. /**
  48289. * Gets stiffness of the impostor
  48290. * @param impostor impostor to get stiffness from
  48291. * @returns pressure value
  48292. */
  48293. getBodyStiffness(impostor: PhysicsImpostor): number;
  48294. /**
  48295. * Sets stiffness of the impostor
  48296. * @param impostor impostor to set stiffness on
  48297. * @param stiffness stiffness value from 0 to 1
  48298. */
  48299. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  48300. /**
  48301. * Gets velocityIterations of the impostor
  48302. * @param impostor impostor to get velocity iterations from
  48303. * @returns velocityIterations value
  48304. */
  48305. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  48306. /**
  48307. * Sets velocityIterations of the impostor
  48308. * @param impostor impostor to set velocity iterations on
  48309. * @param velocityIterations velocityIterations value
  48310. */
  48311. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  48312. /**
  48313. * Gets positionIterations of the impostor
  48314. * @param impostor impostor to get position iterations from
  48315. * @returns positionIterations value
  48316. */
  48317. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  48318. /**
  48319. * Sets positionIterations of the impostor
  48320. * @param impostor impostor to set position on
  48321. * @param positionIterations positionIterations value
  48322. */
  48323. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  48324. /**
  48325. * Append an anchor to a cloth object
  48326. * @param impostor is the cloth impostor to add anchor to
  48327. * @param otherImpostor is the rigid impostor to anchor to
  48328. * @param width ratio across width from 0 to 1
  48329. * @param height ratio up height from 0 to 1
  48330. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  48331. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48332. */
  48333. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48334. /**
  48335. * Append an hook to a rope object
  48336. * @param impostor is the rope impostor to add hook to
  48337. * @param otherImpostor is the rigid impostor to hook to
  48338. * @param length ratio along the rope from 0 to 1
  48339. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  48340. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  48341. */
  48342. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  48343. /**
  48344. * Sleeps the physics body and stops it from being active
  48345. * @param impostor impostor to sleep
  48346. */
  48347. sleepBody(impostor: PhysicsImpostor): void;
  48348. /**
  48349. * Activates the physics body
  48350. * @param impostor impostor to activate
  48351. */
  48352. wakeUpBody(impostor: PhysicsImpostor): void;
  48353. /**
  48354. * Updates the distance parameters of the joint
  48355. * @param joint joint to update
  48356. * @param maxDistance maximum distance of the joint
  48357. * @param minDistance minimum distance of the joint
  48358. */
  48359. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  48360. /**
  48361. * Sets a motor on the joint
  48362. * @param joint joint to set motor on
  48363. * @param speed speed of the motor
  48364. * @param maxForce maximum force of the motor
  48365. * @param motorIndex index of the motor
  48366. */
  48367. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  48368. /**
  48369. * Sets the motors limit
  48370. * @param joint joint to set limit on
  48371. * @param upperLimit upper limit
  48372. * @param lowerLimit lower limit
  48373. */
  48374. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  48375. /**
  48376. * Syncs the position and rotation of a mesh with the impostor
  48377. * @param mesh mesh to sync
  48378. * @param impostor impostor to update the mesh with
  48379. */
  48380. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  48381. /**
  48382. * Gets the radius of the impostor
  48383. * @param impostor impostor to get radius from
  48384. * @returns the radius
  48385. */
  48386. getRadius(impostor: PhysicsImpostor): number;
  48387. /**
  48388. * Gets the box size of the impostor
  48389. * @param impostor impostor to get box size from
  48390. * @param result the resulting box size
  48391. */
  48392. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  48393. /**
  48394. * Disposes of the impostor
  48395. */
  48396. dispose(): void;
  48397. /**
  48398. * Does a raycast in the physics world
  48399. * @param from when should the ray start?
  48400. * @param to when should the ray end?
  48401. * @returns PhysicsRaycastResult
  48402. */
  48403. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  48404. }
  48405. }
  48406. declare module BABYLON {
  48407. interface AbstractScene {
  48408. /**
  48409. * The list of reflection probes added to the scene
  48410. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48411. */
  48412. reflectionProbes: Array<ReflectionProbe>;
  48413. /**
  48414. * Removes the given reflection probe from this scene.
  48415. * @param toRemove The reflection probe to remove
  48416. * @returns The index of the removed reflection probe
  48417. */
  48418. removeReflectionProbe(toRemove: ReflectionProbe): number;
  48419. /**
  48420. * Adds the given reflection probe to this scene.
  48421. * @param newReflectionProbe The reflection probe to add
  48422. */
  48423. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  48424. }
  48425. /**
  48426. * Class used to generate realtime reflection / refraction cube textures
  48427. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  48428. */
  48429. export class ReflectionProbe {
  48430. /** defines the name of the probe */
  48431. name: string;
  48432. private _scene;
  48433. private _renderTargetTexture;
  48434. private _projectionMatrix;
  48435. private _viewMatrix;
  48436. private _target;
  48437. private _add;
  48438. private _attachedMesh;
  48439. private _invertYAxis;
  48440. /** Gets or sets probe position (center of the cube map) */
  48441. position: Vector3;
  48442. /**
  48443. * Creates a new reflection probe
  48444. * @param name defines the name of the probe
  48445. * @param size defines the texture resolution (for each face)
  48446. * @param scene defines the hosting scene
  48447. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  48448. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  48449. */
  48450. constructor(
  48451. /** defines the name of the probe */
  48452. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  48453. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  48454. samples: number;
  48455. /** Gets or sets the refresh rate to use (on every frame by default) */
  48456. refreshRate: number;
  48457. /**
  48458. * Gets the hosting scene
  48459. * @returns a Scene
  48460. */
  48461. getScene(): Scene;
  48462. /** Gets the internal CubeTexture used to render to */
  48463. readonly cubeTexture: RenderTargetTexture;
  48464. /** Gets the list of meshes to render */
  48465. readonly renderList: Nullable<AbstractMesh[]>;
  48466. /**
  48467. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  48468. * @param mesh defines the mesh to attach to
  48469. */
  48470. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  48471. /**
  48472. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  48473. * @param renderingGroupId The rendering group id corresponding to its index
  48474. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  48475. */
  48476. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  48477. /**
  48478. * Clean all associated resources
  48479. */
  48480. dispose(): void;
  48481. /**
  48482. * Converts the reflection probe information to a readable string for debug purpose.
  48483. * @param fullDetails Supports for multiple levels of logging within scene loading
  48484. * @returns the human readable reflection probe info
  48485. */
  48486. toString(fullDetails?: boolean): string;
  48487. /**
  48488. * Get the class name of the relfection probe.
  48489. * @returns "ReflectionProbe"
  48490. */
  48491. getClassName(): string;
  48492. /**
  48493. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  48494. * @returns The JSON representation of the texture
  48495. */
  48496. serialize(): any;
  48497. /**
  48498. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  48499. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  48500. * @param scene Define the scene the parsed reflection probe should be instantiated in
  48501. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  48502. * @returns The parsed reflection probe if successful
  48503. */
  48504. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  48505. }
  48506. }
  48507. declare module BABYLON {
  48508. /** @hidden */
  48509. export var _BabylonLoaderRegistered: boolean;
  48510. }
  48511. declare module BABYLON {
  48512. /**
  48513. * The Physically based simple base material of BJS.
  48514. *
  48515. * This enables better naming and convention enforcements on top of the pbrMaterial.
  48516. * It is used as the base class for both the specGloss and metalRough conventions.
  48517. */
  48518. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  48519. /**
  48520. * Number of Simultaneous lights allowed on the material.
  48521. */
  48522. maxSimultaneousLights: number;
  48523. /**
  48524. * If sets to true, disables all the lights affecting the material.
  48525. */
  48526. disableLighting: boolean;
  48527. /**
  48528. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  48529. */
  48530. environmentTexture: BaseTexture;
  48531. /**
  48532. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  48533. */
  48534. invertNormalMapX: boolean;
  48535. /**
  48536. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  48537. */
  48538. invertNormalMapY: boolean;
  48539. /**
  48540. * Normal map used in the model.
  48541. */
  48542. normalTexture: BaseTexture;
  48543. /**
  48544. * Emissivie color used to self-illuminate the model.
  48545. */
  48546. emissiveColor: Color3;
  48547. /**
  48548. * Emissivie texture used to self-illuminate the model.
  48549. */
  48550. emissiveTexture: BaseTexture;
  48551. /**
  48552. * Occlusion Channel Strenght.
  48553. */
  48554. occlusionStrength: number;
  48555. /**
  48556. * Occlusion Texture of the material (adding extra occlusion effects).
  48557. */
  48558. occlusionTexture: BaseTexture;
  48559. /**
  48560. * Defines the alpha limits in alpha test mode.
  48561. */
  48562. alphaCutOff: number;
  48563. /**
  48564. * Gets the current double sided mode.
  48565. */
  48566. /**
  48567. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  48568. */
  48569. doubleSided: boolean;
  48570. /**
  48571. * Stores the pre-calculated light information of a mesh in a texture.
  48572. */
  48573. lightmapTexture: BaseTexture;
  48574. /**
  48575. * If true, the light map contains occlusion information instead of lighting info.
  48576. */
  48577. useLightmapAsShadowmap: boolean;
  48578. /**
  48579. * Instantiates a new PBRMaterial instance.
  48580. *
  48581. * @param name The material name
  48582. * @param scene The scene the material will be use in.
  48583. */
  48584. constructor(name: string, scene: Scene);
  48585. getClassName(): string;
  48586. }
  48587. }
  48588. declare module BABYLON {
  48589. /**
  48590. * The PBR material of BJS following the metal roughness convention.
  48591. *
  48592. * This fits to the PBR convention in the GLTF definition:
  48593. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  48594. */
  48595. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  48596. /**
  48597. * The base color has two different interpretations depending on the value of metalness.
  48598. * When the material is a metal, the base color is the specific measured reflectance value
  48599. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  48600. * of the material.
  48601. */
  48602. baseColor: Color3;
  48603. /**
  48604. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  48605. * well as opacity information in the alpha channel.
  48606. */
  48607. baseTexture: BaseTexture;
  48608. /**
  48609. * Specifies the metallic scalar value of the material.
  48610. * Can also be used to scale the metalness values of the metallic texture.
  48611. */
  48612. metallic: number;
  48613. /**
  48614. * Specifies the roughness scalar value of the material.
  48615. * Can also be used to scale the roughness values of the metallic texture.
  48616. */
  48617. roughness: number;
  48618. /**
  48619. * Texture containing both the metallic value in the B channel and the
  48620. * roughness value in the G channel to keep better precision.
  48621. */
  48622. metallicRoughnessTexture: BaseTexture;
  48623. /**
  48624. * Instantiates a new PBRMetalRoughnessMaterial instance.
  48625. *
  48626. * @param name The material name
  48627. * @param scene The scene the material will be use in.
  48628. */
  48629. constructor(name: string, scene: Scene);
  48630. /**
  48631. * Return the currrent class name of the material.
  48632. */
  48633. getClassName(): string;
  48634. /**
  48635. * Makes a duplicate of the current material.
  48636. * @param name - name to use for the new material.
  48637. */
  48638. clone(name: string): PBRMetallicRoughnessMaterial;
  48639. /**
  48640. * Serialize the material to a parsable JSON object.
  48641. */
  48642. serialize(): any;
  48643. /**
  48644. * Parses a JSON object correponding to the serialize function.
  48645. */
  48646. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  48647. }
  48648. }
  48649. declare module BABYLON {
  48650. /**
  48651. * The PBR material of BJS following the specular glossiness convention.
  48652. *
  48653. * This fits to the PBR convention in the GLTF definition:
  48654. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  48655. */
  48656. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  48657. /**
  48658. * Specifies the diffuse color of the material.
  48659. */
  48660. diffuseColor: Color3;
  48661. /**
  48662. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  48663. * channel.
  48664. */
  48665. diffuseTexture: BaseTexture;
  48666. /**
  48667. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  48668. */
  48669. specularColor: Color3;
  48670. /**
  48671. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  48672. */
  48673. glossiness: number;
  48674. /**
  48675. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  48676. */
  48677. specularGlossinessTexture: BaseTexture;
  48678. /**
  48679. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  48680. *
  48681. * @param name The material name
  48682. * @param scene The scene the material will be use in.
  48683. */
  48684. constructor(name: string, scene: Scene);
  48685. /**
  48686. * Return the currrent class name of the material.
  48687. */
  48688. getClassName(): string;
  48689. /**
  48690. * Makes a duplicate of the current material.
  48691. * @param name - name to use for the new material.
  48692. */
  48693. clone(name: string): PBRSpecularGlossinessMaterial;
  48694. /**
  48695. * Serialize the material to a parsable JSON object.
  48696. */
  48697. serialize(): any;
  48698. /**
  48699. * Parses a JSON object correponding to the serialize function.
  48700. */
  48701. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  48702. }
  48703. }
  48704. declare module BABYLON {
  48705. /**
  48706. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  48707. * It can help converting any input color in a desired output one. This can then be used to create effects
  48708. * from sepia, black and white to sixties or futuristic rendering...
  48709. *
  48710. * The only supported format is currently 3dl.
  48711. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  48712. */
  48713. export class ColorGradingTexture extends BaseTexture {
  48714. /**
  48715. * The current texture matrix. (will always be identity in color grading texture)
  48716. */
  48717. private _textureMatrix;
  48718. /**
  48719. * The texture URL.
  48720. */
  48721. url: string;
  48722. /**
  48723. * Empty line regex stored for GC.
  48724. */
  48725. private static _noneEmptyLineRegex;
  48726. private _engine;
  48727. /**
  48728. * Instantiates a ColorGradingTexture from the following parameters.
  48729. *
  48730. * @param url The location of the color gradind data (currently only supporting 3dl)
  48731. * @param scene The scene the texture will be used in
  48732. */
  48733. constructor(url: string, scene: Scene);
  48734. /**
  48735. * Returns the texture matrix used in most of the material.
  48736. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  48737. */
  48738. getTextureMatrix(): Matrix;
  48739. /**
  48740. * Occurs when the file being loaded is a .3dl LUT file.
  48741. */
  48742. private load3dlTexture;
  48743. /**
  48744. * Starts the loading process of the texture.
  48745. */
  48746. private loadTexture;
  48747. /**
  48748. * Clones the color gradind texture.
  48749. */
  48750. clone(): ColorGradingTexture;
  48751. /**
  48752. * Called during delayed load for textures.
  48753. */
  48754. delayLoad(): void;
  48755. /**
  48756. * Parses a color grading texture serialized by Babylon.
  48757. * @param parsedTexture The texture information being parsedTexture
  48758. * @param scene The scene to load the texture in
  48759. * @param rootUrl The root url of the data assets to load
  48760. * @return A color gradind texture
  48761. */
  48762. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  48763. /**
  48764. * Serializes the LUT texture to json format.
  48765. */
  48766. serialize(): any;
  48767. }
  48768. }
  48769. declare module BABYLON {
  48770. /**
  48771. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  48772. */
  48773. export class EquiRectangularCubeTexture extends BaseTexture {
  48774. /** The six faces of the cube. */
  48775. private static _FacesMapping;
  48776. private _noMipmap;
  48777. private _onLoad;
  48778. private _onError;
  48779. /** The size of the cubemap. */
  48780. private _size;
  48781. /** The buffer of the image. */
  48782. private _buffer;
  48783. /** The width of the input image. */
  48784. private _width;
  48785. /** The height of the input image. */
  48786. private _height;
  48787. /** The URL to the image. */
  48788. url: string;
  48789. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  48790. coordinatesMode: number;
  48791. /**
  48792. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  48793. * @param url The location of the image
  48794. * @param scene The scene the texture will be used in
  48795. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  48796. * @param noMipmap Forces to not generate the mipmap if true
  48797. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  48798. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  48799. * @param onLoad — defines a callback called when texture is loaded
  48800. * @param onError — defines a callback called if there is an error
  48801. */
  48802. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  48803. /**
  48804. * Load the image data, by putting the image on a canvas and extracting its buffer.
  48805. */
  48806. private loadImage;
  48807. /**
  48808. * Convert the image buffer into a cubemap and create a CubeTexture.
  48809. */
  48810. private loadTexture;
  48811. /**
  48812. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  48813. * @param buffer The ArrayBuffer that should be converted.
  48814. * @returns The buffer as Float32Array.
  48815. */
  48816. private getFloat32ArrayFromArrayBuffer;
  48817. /**
  48818. * Get the current class name of the texture useful for serialization or dynamic coding.
  48819. * @returns "EquiRectangularCubeTexture"
  48820. */
  48821. getClassName(): string;
  48822. /**
  48823. * Create a clone of the current EquiRectangularCubeTexture and return it.
  48824. * @returns A clone of the current EquiRectangularCubeTexture.
  48825. */
  48826. clone(): EquiRectangularCubeTexture;
  48827. }
  48828. }
  48829. declare module BABYLON {
  48830. /**
  48831. * Based on jsTGALoader - Javascript loader for TGA file
  48832. * By Vincent Thibault
  48833. * @see http://blog.robrowser.com/javascript-tga-loader.html
  48834. */
  48835. export class TGATools {
  48836. private static _TYPE_INDEXED;
  48837. private static _TYPE_RGB;
  48838. private static _TYPE_GREY;
  48839. private static _TYPE_RLE_INDEXED;
  48840. private static _TYPE_RLE_RGB;
  48841. private static _TYPE_RLE_GREY;
  48842. private static _ORIGIN_MASK;
  48843. private static _ORIGIN_SHIFT;
  48844. private static _ORIGIN_BL;
  48845. private static _ORIGIN_BR;
  48846. private static _ORIGIN_UL;
  48847. private static _ORIGIN_UR;
  48848. /**
  48849. * Gets the header of a TGA file
  48850. * @param data defines the TGA data
  48851. * @returns the header
  48852. */
  48853. static GetTGAHeader(data: Uint8Array): any;
  48854. /**
  48855. * Uploads TGA content to a Babylon Texture
  48856. * @hidden
  48857. */
  48858. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  48859. /** @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;
  48860. /** @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;
  48861. /** @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;
  48862. /** @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;
  48863. /** @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;
  48864. /** @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;
  48865. }
  48866. }
  48867. declare module BABYLON {
  48868. /**
  48869. * Implementation of the TGA Texture Loader.
  48870. * @hidden
  48871. */
  48872. export class _TGATextureLoader implements IInternalTextureLoader {
  48873. /**
  48874. * Defines wether the loader supports cascade loading the different faces.
  48875. */
  48876. readonly supportCascades: boolean;
  48877. /**
  48878. * This returns if the loader support the current file information.
  48879. * @param extension defines the file extension of the file being loaded
  48880. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48881. * @param fallback defines the fallback internal texture if any
  48882. * @param isBase64 defines whether the texture is encoded as a base64
  48883. * @param isBuffer defines whether the texture data are stored as a buffer
  48884. * @returns true if the loader can load the specified file
  48885. */
  48886. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48887. /**
  48888. * Transform the url before loading if required.
  48889. * @param rootUrl the url of the texture
  48890. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48891. * @returns the transformed texture
  48892. */
  48893. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48894. /**
  48895. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48896. * @param rootUrl the url of the texture
  48897. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48898. * @returns the fallback texture
  48899. */
  48900. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48901. /**
  48902. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48903. * @param data contains the texture data
  48904. * @param texture defines the BabylonJS internal texture
  48905. * @param createPolynomials will be true if polynomials have been requested
  48906. * @param onLoad defines the callback to trigger once the texture is ready
  48907. * @param onError defines the callback to trigger in case of error
  48908. */
  48909. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48910. /**
  48911. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48912. * @param data contains the texture data
  48913. * @param texture defines the BabylonJS internal texture
  48914. * @param callback defines the method to call once ready to upload
  48915. */
  48916. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48917. }
  48918. }
  48919. declare module BABYLON {
  48920. /**
  48921. * 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.
  48922. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48924. */
  48925. export class CustomProceduralTexture extends ProceduralTexture {
  48926. private _animate;
  48927. private _time;
  48928. private _config;
  48929. private _texturePath;
  48930. /**
  48931. * Instantiates a new Custom Procedural Texture.
  48932. * 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.
  48933. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  48934. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  48935. * @param name Define the name of the texture
  48936. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  48937. * @param size Define the size of the texture to create
  48938. * @param scene Define the scene the texture belongs to
  48939. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  48940. * @param generateMipMaps Define if the texture should creates mip maps or not
  48941. */
  48942. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48943. private _loadJson;
  48944. /**
  48945. * Is the texture ready to be used ? (rendered at least once)
  48946. * @returns true if ready, otherwise, false.
  48947. */
  48948. isReady(): boolean;
  48949. /**
  48950. * Render the texture to its associated render target.
  48951. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  48952. */
  48953. render(useCameraPostProcess?: boolean): void;
  48954. /**
  48955. * Update the list of dependant textures samplers in the shader.
  48956. */
  48957. updateTextures(): void;
  48958. /**
  48959. * Update the uniform values of the procedural texture in the shader.
  48960. */
  48961. updateShaderUniforms(): void;
  48962. /**
  48963. * Define if the texture animates or not.
  48964. */
  48965. animate: boolean;
  48966. }
  48967. }
  48968. declare module BABYLON {
  48969. /** @hidden */
  48970. export var noisePixelShader: {
  48971. name: string;
  48972. shader: string;
  48973. };
  48974. }
  48975. declare module BABYLON {
  48976. /**
  48977. * Class used to generate noise procedural textures
  48978. */
  48979. export class NoiseProceduralTexture extends ProceduralTexture {
  48980. private _time;
  48981. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  48982. brightness: number;
  48983. /** Defines the number of octaves to process */
  48984. octaves: number;
  48985. /** Defines the level of persistence (0.8 by default) */
  48986. persistence: number;
  48987. /** Gets or sets animation speed factor (default is 1) */
  48988. animationSpeedFactor: number;
  48989. /**
  48990. * Creates a new NoiseProceduralTexture
  48991. * @param name defines the name fo the texture
  48992. * @param size defines the size of the texture (default is 256)
  48993. * @param scene defines the hosting scene
  48994. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  48995. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  48996. */
  48997. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  48998. private _updateShaderUniforms;
  48999. protected _getDefines(): string;
  49000. /** Generate the current state of the procedural texture */
  49001. render(useCameraPostProcess?: boolean): void;
  49002. /**
  49003. * Serializes this noise procedural texture
  49004. * @returns a serialized noise procedural texture object
  49005. */
  49006. serialize(): any;
  49007. /**
  49008. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  49009. * @param parsedTexture defines parsed texture data
  49010. * @param scene defines the current scene
  49011. * @param rootUrl defines the root URL containing noise procedural texture information
  49012. * @returns a parsed NoiseProceduralTexture
  49013. */
  49014. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  49015. }
  49016. }
  49017. declare module BABYLON {
  49018. /**
  49019. * Raw cube texture where the raw buffers are passed in
  49020. */
  49021. export class RawCubeTexture extends CubeTexture {
  49022. /**
  49023. * Creates a cube texture where the raw buffers are passed in.
  49024. * @param scene defines the scene the texture is attached to
  49025. * @param data defines the array of data to use to create each face
  49026. * @param size defines the size of the textures
  49027. * @param format defines the format of the data
  49028. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  49029. * @param generateMipMaps defines if the engine should generate the mip levels
  49030. * @param invertY defines if data must be stored with Y axis inverted
  49031. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  49032. * @param compression defines the compression used (null by default)
  49033. */
  49034. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  49035. /**
  49036. * Updates the raw cube texture.
  49037. * @param data defines the data to store
  49038. * @param format defines the data format
  49039. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  49040. * @param invertY defines if data must be stored with Y axis inverted
  49041. * @param compression defines the compression used (null by default)
  49042. * @param level defines which level of the texture to update
  49043. */
  49044. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  49045. /**
  49046. * Updates a raw cube texture with RGBD encoded data.
  49047. * @param data defines the array of data [mipmap][face] to use to create each face
  49048. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  49049. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49050. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49051. * @returns a promsie that resolves when the operation is complete
  49052. */
  49053. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  49054. /**
  49055. * Clones the raw cube texture.
  49056. * @return a new cube texture
  49057. */
  49058. clone(): CubeTexture;
  49059. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49060. }
  49061. }
  49062. declare module BABYLON {
  49063. /**
  49064. * Class used to store 3D textures containing user data
  49065. */
  49066. export class RawTexture3D extends Texture {
  49067. /** Gets or sets the texture format to use */
  49068. format: number;
  49069. private _engine;
  49070. /**
  49071. * Create a new RawTexture3D
  49072. * @param data defines the data of the texture
  49073. * @param width defines the width of the texture
  49074. * @param height defines the height of the texture
  49075. * @param depth defines the depth of the texture
  49076. * @param format defines the texture format to use
  49077. * @param scene defines the hosting scene
  49078. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  49079. * @param invertY defines if texture must be stored with Y axis inverted
  49080. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  49081. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  49082. */
  49083. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  49084. /** Gets or sets the texture format to use */
  49085. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  49086. /**
  49087. * Update the texture with new data
  49088. * @param data defines the data to store in the texture
  49089. */
  49090. update(data: ArrayBufferView): void;
  49091. }
  49092. }
  49093. declare module BABYLON {
  49094. /**
  49095. * Creates a refraction texture used by refraction channel of the standard material.
  49096. * It is like a mirror but to see through a material.
  49097. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49098. */
  49099. export class RefractionTexture extends RenderTargetTexture {
  49100. /**
  49101. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  49102. * 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.
  49103. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49104. */
  49105. refractionPlane: Plane;
  49106. /**
  49107. * Define how deep under the surface we should see.
  49108. */
  49109. depth: number;
  49110. /**
  49111. * Creates a refraction texture used by refraction channel of the standard material.
  49112. * It is like a mirror but to see through a material.
  49113. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  49114. * @param name Define the texture name
  49115. * @param size Define the size of the underlying texture
  49116. * @param scene Define the scene the refraction belongs to
  49117. * @param generateMipMaps Define if we need to generate mips level for the refraction
  49118. */
  49119. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  49120. /**
  49121. * Clone the refraction texture.
  49122. * @returns the cloned texture
  49123. */
  49124. clone(): RefractionTexture;
  49125. /**
  49126. * Serialize the texture to a JSON representation you could use in Parse later on
  49127. * @returns the serialized JSON representation
  49128. */
  49129. serialize(): any;
  49130. }
  49131. }
  49132. declare module BABYLON {
  49133. /**
  49134. * Defines the options related to the creation of an HtmlElementTexture
  49135. */
  49136. export interface IHtmlElementTextureOptions {
  49137. /**
  49138. * Defines wether mip maps should be created or not.
  49139. */
  49140. generateMipMaps?: boolean;
  49141. /**
  49142. * Defines the sampling mode of the texture.
  49143. */
  49144. samplingMode?: number;
  49145. /**
  49146. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  49147. */
  49148. engine: Nullable<Engine>;
  49149. /**
  49150. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  49151. */
  49152. scene: Nullable<Scene>;
  49153. }
  49154. /**
  49155. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  49156. * To be as efficient as possible depending on your constraints nothing aside the first upload
  49157. * is automatically managed.
  49158. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  49159. * in your application.
  49160. *
  49161. * As the update is not automatic, you need to call them manually.
  49162. */
  49163. export class HtmlElementTexture extends BaseTexture {
  49164. /**
  49165. * The texture URL.
  49166. */
  49167. element: HTMLVideoElement | HTMLCanvasElement;
  49168. private static readonly DefaultOptions;
  49169. private _textureMatrix;
  49170. private _engine;
  49171. private _isVideo;
  49172. private _generateMipMaps;
  49173. private _samplingMode;
  49174. /**
  49175. * Instantiates a HtmlElementTexture from the following parameters.
  49176. *
  49177. * @param name Defines the name of the texture
  49178. * @param element Defines the video or canvas the texture is filled with
  49179. * @param options Defines the other none mandatory texture creation options
  49180. */
  49181. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  49182. private _createInternalTexture;
  49183. /**
  49184. * Returns the texture matrix used in most of the material.
  49185. */
  49186. getTextureMatrix(): Matrix;
  49187. /**
  49188. * Updates the content of the texture.
  49189. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  49190. */
  49191. update(invertY?: Nullable<boolean>): void;
  49192. }
  49193. }
  49194. declare module BABYLON {
  49195. /**
  49196. * Enum used to define the target of a block
  49197. */
  49198. export enum NodeMaterialBlockTargets {
  49199. /** Vertex shader */
  49200. Vertex = 1,
  49201. /** Fragment shader */
  49202. Fragment = 2,
  49203. /** Vertex and Fragment */
  49204. VertexAndFragment = 3
  49205. }
  49206. }
  49207. declare module BABYLON {
  49208. /**
  49209. * Defines the kind of connection point for node based material
  49210. */
  49211. export enum NodeMaterialBlockConnectionPointTypes {
  49212. /** Float */
  49213. Float = 1,
  49214. /** Int */
  49215. Int = 2,
  49216. /** Vector2 */
  49217. Vector2 = 4,
  49218. /** Vector3 */
  49219. Vector3 = 8,
  49220. /** Vector4 */
  49221. Vector4 = 16,
  49222. /** Color3 */
  49223. Color3 = 32,
  49224. /** Color4 */
  49225. Color4 = 64,
  49226. /** Matrix */
  49227. Matrix = 128,
  49228. /** Texture */
  49229. Texture = 256,
  49230. /** Texture3D */
  49231. Texture3D = 512,
  49232. /** Vector3 or Color3 */
  49233. Vector3OrColor3 = 40,
  49234. /** Vector3 or Vector4 */
  49235. Vector3OrVector4 = 24,
  49236. /** Vector4 or Color4 */
  49237. Vector4OrColor4 = 80,
  49238. /** Color3 or Color4 */
  49239. Color3OrColor4 = 96,
  49240. /** Vector3 or Color3 */
  49241. Vector3OrColor3OrVector4OrColor4 = 120
  49242. }
  49243. }
  49244. declare module BABYLON {
  49245. /**
  49246. * Enum used to define well known values e.g. values automatically provided by the system
  49247. */
  49248. export enum NodeMaterialWellKnownValues {
  49249. /** World */
  49250. World = 1,
  49251. /** View */
  49252. View = 2,
  49253. /** Projection */
  49254. Projection = 3,
  49255. /** ViewProjection */
  49256. ViewProjection = 4,
  49257. /** WorldView */
  49258. WorldView = 5,
  49259. /** WorldViewProjection */
  49260. WorldViewProjection = 6,
  49261. /** Will be filled by the block itself */
  49262. BlockBased = 7
  49263. }
  49264. }
  49265. declare module BABYLON {
  49266. /**
  49267. * Class used to store shared data between 2 NodeMaterialBuildState
  49268. */
  49269. export class NodeMaterialBuildStateSharedData {
  49270. /**
  49271. * Gets the list of emitted varyings
  49272. */
  49273. varyings: string[];
  49274. /**
  49275. * Gets the varying declaration string
  49276. */
  49277. varyingDeclaration: string;
  49278. /**
  49279. * Uniform connection points
  49280. */
  49281. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  49282. /**
  49283. * Bindable blocks (Blocks that need to set data to the effect)
  49284. */
  49285. bindableBlocks: NodeMaterialBlock[];
  49286. /**
  49287. * List of blocks that can provide a compilation fallback
  49288. */
  49289. blocksWithFallbacks: NodeMaterialBlock[];
  49290. /**
  49291. * List of blocks that can provide a define update
  49292. */
  49293. blocksWithDefines: NodeMaterialBlock[];
  49294. /**
  49295. * List of blocks that can provide a repeatable content
  49296. */
  49297. repeatableContentBlocks: NodeMaterialBlock[];
  49298. /**
  49299. * List of blocks that can block the isReady function for the material
  49300. */
  49301. blockingBlocks: NodeMaterialBlock[];
  49302. /**
  49303. * Build Id used to avoid multiple recompilations
  49304. */
  49305. buildId: number;
  49306. /** List of emitted variables */
  49307. variableNames: {
  49308. [key: string]: number;
  49309. };
  49310. /** List of emitted defines */
  49311. defineNames: {
  49312. [key: string]: number;
  49313. };
  49314. /** Should emit comments? */
  49315. emitComments: boolean;
  49316. /** Emit build activity */
  49317. verbose: boolean;
  49318. /**
  49319. * Gets the compilation hints emitted at compilation time
  49320. */
  49321. hints: {
  49322. needWorldViewMatrix: boolean;
  49323. needWorldViewProjectionMatrix: boolean;
  49324. needAlphaBlending: boolean;
  49325. needAlphaTesting: boolean;
  49326. };
  49327. /**
  49328. * List of compilation checks
  49329. */
  49330. checks: {
  49331. emitVertex: boolean;
  49332. emitFragment: boolean;
  49333. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  49334. };
  49335. /** Creates a new shared data */
  49336. constructor();
  49337. /**
  49338. * Emits console errors and exceptions if there is a failing check
  49339. */
  49340. emitErrors(): void;
  49341. }
  49342. }
  49343. declare module BABYLON {
  49344. /**
  49345. * Class used to store node based material build state
  49346. */
  49347. export class NodeMaterialBuildState {
  49348. /**
  49349. * Gets the list of emitted attributes
  49350. */
  49351. attributes: string[];
  49352. /**
  49353. * Gets the list of emitted uniforms
  49354. */
  49355. uniforms: string[];
  49356. /**
  49357. * Gets the list of emitted samplers
  49358. */
  49359. samplers: string[];
  49360. /**
  49361. * Gets the list of emitted functions
  49362. */
  49363. functions: {
  49364. [key: string]: string;
  49365. };
  49366. /**
  49367. * Gets the target of the compilation state
  49368. */
  49369. target: NodeMaterialBlockTargets;
  49370. /**
  49371. * Shared data between multiple NodeMaterialBuildState instances
  49372. */
  49373. sharedData: NodeMaterialBuildStateSharedData;
  49374. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  49375. private _attributeDeclaration;
  49376. private _uniformDeclaration;
  49377. private _samplerDeclaration;
  49378. private _varyingTransfer;
  49379. private _repeatableContentAnchorIndex;
  49380. /** @hidden */ private _builtCompilationString: string;
  49381. /**
  49382. * Gets the emitted compilation strings
  49383. */
  49384. compilationString: string;
  49385. /**
  49386. * Finalize the compilation strings
  49387. * @param state defines the current compilation state
  49388. */
  49389. finalize(state: NodeMaterialBuildState): void;
  49390. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  49391. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  49392. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  49393. /** @hidden */ private _excludeVariableName(name: string): void;
  49394. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  49395. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  49396. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  49397. replaceStrings?: {
  49398. search: RegExp;
  49399. replace: string;
  49400. }[];
  49401. }): string;
  49402. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  49403. repeatKey?: string;
  49404. removeAttributes?: boolean;
  49405. removeUniforms?: boolean;
  49406. removeVaryings?: boolean;
  49407. removeIfDef?: boolean;
  49408. replaceStrings?: {
  49409. search: RegExp;
  49410. replace: string;
  49411. }[];
  49412. }): void;
  49413. /** @hidden */ private _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  49414. private _emitDefine;
  49415. /** @hidden */ private _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  49416. }
  49417. }
  49418. declare module BABYLON {
  49419. /**
  49420. * Root class for all node material optimizers
  49421. */
  49422. export class NodeMaterialOptimizer {
  49423. /**
  49424. * Function used to optimize a NodeMaterial graph
  49425. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  49426. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  49427. */
  49428. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  49429. }
  49430. }
  49431. declare module BABYLON {
  49432. /**
  49433. * Interface used to configure the node material editor
  49434. */
  49435. export interface INodeMaterialEditorOptions {
  49436. /** Define the URl to load node editor script */
  49437. editorURL?: string;
  49438. }
  49439. /** @hidden */
  49440. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  49441. /** BONES */
  49442. NUM_BONE_INFLUENCERS: number;
  49443. BonesPerMesh: number;
  49444. BONETEXTURE: boolean;
  49445. /** MORPH TARGETS */
  49446. MORPHTARGETS: boolean;
  49447. MORPHTARGETS_NORMAL: boolean;
  49448. MORPHTARGETS_TANGENT: boolean;
  49449. NUM_MORPH_INFLUENCERS: number;
  49450. /** IMAGE PROCESSING */
  49451. IMAGEPROCESSING: boolean;
  49452. VIGNETTE: boolean;
  49453. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49454. VIGNETTEBLENDMODEOPAQUE: boolean;
  49455. TONEMAPPING: boolean;
  49456. TONEMAPPING_ACES: boolean;
  49457. CONTRAST: boolean;
  49458. EXPOSURE: boolean;
  49459. COLORCURVES: boolean;
  49460. COLORGRADING: boolean;
  49461. COLORGRADING3D: boolean;
  49462. SAMPLER3DGREENDEPTH: boolean;
  49463. SAMPLER3DBGRMAP: boolean;
  49464. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49465. constructor();
  49466. setValue(name: string, value: boolean): void;
  49467. }
  49468. /**
  49469. * Class used to configure NodeMaterial
  49470. */
  49471. export interface INodeMaterialOptions {
  49472. /**
  49473. * Defines if blocks should emit comments
  49474. */
  49475. emitComments: boolean;
  49476. }
  49477. /**
  49478. * Class used to create a node based material built by assembling shader blocks
  49479. */
  49480. export class NodeMaterial extends PushMaterial {
  49481. private _options;
  49482. private _vertexCompilationState;
  49483. private _fragmentCompilationState;
  49484. private _sharedData;
  49485. private _buildId;
  49486. private _buildWasSuccessful;
  49487. private _cachedWorldViewMatrix;
  49488. private _cachedWorldViewProjectionMatrix;
  49489. private _textureConnectionPoints;
  49490. private _optimizers;
  49491. /** Define the URl to load node editor script */
  49492. static EditorURL: string;
  49493. private BJSNODEMATERIALEDITOR;
  49494. /** Get the inspector from bundle or global */
  49495. private _getGlobalNodeMaterialEditor;
  49496. /**
  49497. * Defines the maximum number of lights that can be used in the material
  49498. */
  49499. maxSimultaneousLights: number;
  49500. /**
  49501. * Observable raised when the material is built
  49502. */
  49503. onBuildObservable: Observable<NodeMaterial>;
  49504. /**
  49505. * Gets or sets the root nodes of the material vertex shader
  49506. */ private _vertexOutputNodes: NodeMaterialBlock[];
  49507. /**
  49508. * Gets or sets the root nodes of the material fragment (pixel) shader
  49509. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  49510. /** Gets or sets options to control the node material overall behavior */
  49511. options: INodeMaterialOptions;
  49512. /**
  49513. * Default configuration related to image processing available in the standard Material.
  49514. */
  49515. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49516. /**
  49517. * Gets the image processing configuration used either in this material.
  49518. */
  49519. /**
  49520. * Sets the Default image processing configuration used either in the this material.
  49521. *
  49522. * If sets to null, the scene one is in use.
  49523. */
  49524. imageProcessingConfiguration: ImageProcessingConfiguration;
  49525. /**
  49526. * Create a new node based material
  49527. * @param name defines the material name
  49528. * @param scene defines the hosting scene
  49529. * @param options defines creation option
  49530. */
  49531. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  49532. /**
  49533. * Gets the current class name of the material e.g. "NodeMaterial"
  49534. * @returns the class name
  49535. */
  49536. getClassName(): string;
  49537. /**
  49538. * Keep track of the image processing observer to allow dispose and replace.
  49539. */
  49540. private _imageProcessingObserver;
  49541. /**
  49542. * Attaches a new image processing configuration to the Standard Material.
  49543. * @param configuration
  49544. */
  49545. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49546. /**
  49547. * Adds a new optimizer to the list of optimizers
  49548. * @param optimizer defines the optimizers to add
  49549. * @returns the current material
  49550. */
  49551. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  49552. /**
  49553. * Remove an optimizer from the list of optimizers
  49554. * @param optimizer defines the optimizers to remove
  49555. * @returns the current material
  49556. */
  49557. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  49558. /**
  49559. * Add a new block to the list of output nodes
  49560. * @param node defines the node to add
  49561. * @returns the current material
  49562. */
  49563. addOutputNode(node: NodeMaterialBlock): this;
  49564. /**
  49565. * Remove a block from the list of root nodes
  49566. * @param node defines the node to remove
  49567. * @returns the current material
  49568. */
  49569. removeOutputNode(node: NodeMaterialBlock): this;
  49570. private _addVertexOutputNode;
  49571. private _removeVertexOutputNode;
  49572. private _addFragmentOutputNode;
  49573. private _removeFragmentOutputNode;
  49574. /**
  49575. * Specifies if the material will require alpha blending
  49576. * @returns a boolean specifying if alpha blending is needed
  49577. */
  49578. needAlphaBlending(): boolean;
  49579. /**
  49580. * Specifies if this material should be rendered in alpha test mode
  49581. * @returns a boolean specifying if an alpha test is needed.
  49582. */
  49583. needAlphaTesting(): boolean;
  49584. private _initializeBlock;
  49585. private _resetDualBlocks;
  49586. /**
  49587. * Build the material and generates the inner effect
  49588. * @param verbose defines if the build should log activity
  49589. */
  49590. build(verbose?: boolean): void;
  49591. /**
  49592. * Runs an otpimization phase to try to improve the shader code
  49593. */
  49594. optimize(): void;
  49595. private _prepareDefinesForAttributes;
  49596. /**
  49597. * Get if the submesh is ready to be used and all its information available.
  49598. * Child classes can use it to update shaders
  49599. * @param mesh defines the mesh to check
  49600. * @param subMesh defines which submesh to check
  49601. * @param useInstances specifies that instances should be used
  49602. * @returns a boolean indicating that the submesh is ready or not
  49603. */
  49604. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  49605. /**
  49606. * Binds the world matrix to the material
  49607. * @param world defines the world transformation matrix
  49608. */
  49609. bindOnlyWorldMatrix(world: Matrix): void;
  49610. /**
  49611. * Binds the submesh to this material by preparing the effect and shader to draw
  49612. * @param world defines the world transformation matrix
  49613. * @param mesh defines the mesh containing the submesh
  49614. * @param subMesh defines the submesh to bind the material to
  49615. */
  49616. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  49617. /**
  49618. * Gets the active textures from the material
  49619. * @returns an array of textures
  49620. */
  49621. getActiveTextures(): BaseTexture[];
  49622. /**
  49623. * Specifies if the material uses a texture
  49624. * @param texture defines the texture to check against the material
  49625. * @returns a boolean specifying if the material uses the texture
  49626. */
  49627. hasTexture(texture: BaseTexture): boolean;
  49628. /**
  49629. * Disposes the material
  49630. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  49631. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  49632. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  49633. */
  49634. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  49635. /** Creates the node editor window. */
  49636. private _createNodeEditor;
  49637. /**
  49638. * Launch the node material editor
  49639. * @param config Define the configuration of the editor
  49640. * @return a promise fulfilled when the node editor is visible
  49641. */
  49642. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  49643. }
  49644. }
  49645. declare module BABYLON {
  49646. /**
  49647. * Defines a block that can be used inside a node based material
  49648. */
  49649. export class NodeMaterialBlock {
  49650. private _buildId;
  49651. private _target;
  49652. private _isFinalMerger;
  49653. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  49654. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  49655. /**
  49656. * Gets or sets the name of the block
  49657. */
  49658. name: string;
  49659. /**
  49660. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  49661. */
  49662. readonly isFinalMerger: boolean;
  49663. /**
  49664. * Gets or sets the build Id
  49665. */
  49666. buildId: number;
  49667. /**
  49668. * Gets or sets the target of the block
  49669. */
  49670. target: NodeMaterialBlockTargets;
  49671. /**
  49672. * Gets the list of input points
  49673. */
  49674. readonly inputs: NodeMaterialConnectionPoint[];
  49675. /** Gets the list of output points */
  49676. readonly outputs: NodeMaterialConnectionPoint[];
  49677. /**
  49678. * Find an input by its name
  49679. * @param name defines the name of the input to look for
  49680. * @returns the input or null if not found
  49681. */
  49682. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  49683. /**
  49684. * Find an output by its name
  49685. * @param name defines the name of the outputto look for
  49686. * @returns the output or null if not found
  49687. */
  49688. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  49689. /**
  49690. * Creates a new NodeMaterialBlock
  49691. * @param name defines the block name
  49692. * @param target defines the target of that block (Vertex by default)
  49693. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  49694. */
  49695. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  49696. /**
  49697. * Initialize the block and prepare the context for build
  49698. * @param state defines the state that will be used for the build
  49699. */
  49700. initialize(state: NodeMaterialBuildState): void;
  49701. /**
  49702. * Bind data to effect. Will only be called for blocks with isBindable === true
  49703. * @param effect defines the effect to bind data to
  49704. * @param nodeMaterial defines the hosting NodeMaterial
  49705. * @param mesh defines the mesh that will be rendered
  49706. */
  49707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  49708. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  49709. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  49710. protected _writeFloat(value: number): string;
  49711. /**
  49712. * Gets the current class name e.g. "NodeMaterialBlock"
  49713. * @returns the class name
  49714. */
  49715. getClassName(): string;
  49716. /**
  49717. * Register a new input. Must be called inside a block constructor
  49718. * @param name defines the connection point name
  49719. * @param type defines the connection point type
  49720. * @param isOptional defines a boolean indicating that this input can be omitted
  49721. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  49722. * @returns the current block
  49723. */
  49724. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  49725. /**
  49726. * Register a new output. Must be called inside a block constructor
  49727. * @param name defines the connection point name
  49728. * @param type defines the connection point type
  49729. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  49730. * @returns the current block
  49731. */
  49732. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  49733. /**
  49734. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  49735. * @param forOutput defines an optional connection point to check compatibility with
  49736. * @returns the first available input or null
  49737. */
  49738. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  49739. /**
  49740. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  49741. * @param forBlock defines an optional block to check compatibility with
  49742. * @returns the first available input or null
  49743. */
  49744. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  49745. /**
  49746. * Connect current block with another block
  49747. * @param other defines the block to connect with
  49748. * @param options define the various options to help pick the right connections
  49749. * @returns the current block
  49750. */
  49751. connectTo(other: NodeMaterialBlock, options?: {
  49752. input?: string;
  49753. output?: string;
  49754. outputSwizzle?: string;
  49755. }): this | undefined;
  49756. protected _buildBlock(state: NodeMaterialBuildState): void;
  49757. /**
  49758. * Add potential fallbacks if shader compilation fails
  49759. * @param mesh defines the mesh to be rendered
  49760. * @param fallbacks defines the current prioritized list of fallbacks
  49761. */
  49762. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  49763. /**
  49764. * Update defines for shader compilation
  49765. * @param mesh defines the mesh to be rendered
  49766. * @param nodeMaterial defines the node material requesting the update
  49767. * @param defines defines the material defines to update
  49768. * @param useInstances specifies that instances should be used
  49769. */
  49770. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  49771. /**
  49772. * Lets the block try to connect some inputs automatically
  49773. */
  49774. autoConfigure(): void;
  49775. /**
  49776. * Function called when a block is declared as repeatable content generator
  49777. * @param vertexShaderState defines the current compilation state for the vertex shader
  49778. * @param fragmentShaderState defines the current compilation state for the fragment shader
  49779. * @param mesh defines the mesh to be rendered
  49780. * @param defines defines the material defines to update
  49781. */
  49782. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  49783. /**
  49784. * Checks if the block is ready
  49785. * @param mesh defines the mesh to be rendered
  49786. * @param nodeMaterial defines the node material requesting the update
  49787. * @param defines defines the material defines to update
  49788. * @param useInstances specifies that instances should be used
  49789. * @returns true if the block is ready
  49790. */
  49791. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  49792. /**
  49793. * Compile the current node and generate the shader code
  49794. * @param state defines the current compilation state (uniforms, samplers, current string)
  49795. * @returns the current block
  49796. */
  49797. build(state: NodeMaterialBuildState): this | undefined;
  49798. }
  49799. }
  49800. declare module BABYLON {
  49801. /**
  49802. * Defines a connection point for a block
  49803. */
  49804. export class NodeMaterialConnectionPoint {
  49805. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  49806. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  49807. private _associatedVariableName;
  49808. private _endpoints;
  49809. private _storedValue;
  49810. private _valueCallback;
  49811. private _isVarying;
  49812. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  49813. /**
  49814. * Gets or sets the connection point type (default is float)
  49815. */
  49816. type: NodeMaterialBlockConnectionPointTypes;
  49817. /**
  49818. * Gets or sets the connection point name
  49819. */
  49820. name: string;
  49821. /**
  49822. * Gets or sets the swizzle to apply to this connection point when reading or writing
  49823. */
  49824. swizzle: string;
  49825. /**
  49826. * Gets or sets a boolean indicating that this connection point can be omitted
  49827. */
  49828. isOptional: boolean;
  49829. /**
  49830. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  49831. */
  49832. define: string;
  49833. /** Gets or sets the target of that connection point */
  49834. target: NodeMaterialBlockTargets;
  49835. /**
  49836. * Gets or sets the value of that point.
  49837. * Please note that this value will be ignored if valueCallback is defined
  49838. */
  49839. value: any;
  49840. /**
  49841. * Gets or sets a callback used to get the value of that point.
  49842. * Please note that setting this value will force the connection point to ignore the value property
  49843. */
  49844. valueCallback: () => any;
  49845. /**
  49846. * Gets or sets the associated variable name in the shader
  49847. */
  49848. associatedVariableName: string;
  49849. /**
  49850. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  49851. * In this case the connection point name must be the name of the uniform to use.
  49852. * Can only be set on inputs
  49853. */
  49854. isUniform: boolean;
  49855. /**
  49856. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  49857. * In this case the connection point name must be the name of the attribute to use
  49858. * Can only be set on inputs
  49859. */
  49860. isAttribute: boolean;
  49861. /**
  49862. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  49863. * Can only be set on exit points
  49864. */
  49865. isVarying: boolean;
  49866. /** Get the other side of the connection (if any) */
  49867. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  49868. /** Get the block that owns this connection point */
  49869. readonly ownerBlock: NodeMaterialBlock;
  49870. /** Get the block connected on the other side of this connection (if any) */
  49871. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  49872. /** Get the block connected on the endpoints of this connection (if any) */
  49873. readonly connectedBlocks: Array<NodeMaterialBlock>;
  49874. /**
  49875. * Creates a new connection point
  49876. * @param name defines the connection point name
  49877. * @param ownerBlock defines the block hosting this connection point
  49878. */
  49879. constructor(name: string, ownerBlock: NodeMaterialBlock);
  49880. /**
  49881. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  49882. * @returns the class name
  49883. */
  49884. getClassName(): string;
  49885. /**
  49886. * Set the source of this connection point to a vertex attribute
  49887. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  49888. * @returns the current connection point
  49889. */
  49890. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  49891. /**
  49892. * Set the source of this connection point to a well known value
  49893. * @param value define the well known value to use (world, view, etc...)
  49894. * @returns the current connection point
  49895. */
  49896. setAsWellKnownValue(value: NodeMaterialWellKnownValues): NodeMaterialConnectionPoint;
  49897. private _getTypeLength;
  49898. /**
  49899. * Connect this point to another connection point
  49900. * @param connectionPoint defines the other connection point
  49901. * @returns the current connection point
  49902. */
  49903. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  49904. /**
  49905. * Disconnect this point from one of his endpoint
  49906. * @param endpoint defines the other connection point
  49907. * @returns the current connection point
  49908. */
  49909. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  49910. /**
  49911. * When connection point is an uniform, this function will send its value to the effect
  49912. * @param effect defines the effect to transmit value to
  49913. * @param world defines the world matrix
  49914. * @param worldView defines the worldxview matrix
  49915. * @param worldViewProjection defines the worldxviewxprojection matrix
  49916. */
  49917. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  49918. /**
  49919. * When connection point is an uniform, this function will send its value to the effect
  49920. * @param effect defines the effect to transmit value to
  49921. * @param scene defines the hosting scene
  49922. */
  49923. transmit(effect: Effect, scene: Scene): void;
  49924. }
  49925. }
  49926. declare module BABYLON {
  49927. /**
  49928. * Block used to output the vertex position
  49929. */
  49930. export class VertexOutputBlock extends NodeMaterialBlock {
  49931. /**
  49932. * Creates a new VertexOutputBlock
  49933. * @param name defines the block name
  49934. */
  49935. constructor(name: string);
  49936. /**
  49937. * Gets the current class name
  49938. * @returns the class name
  49939. */
  49940. getClassName(): string;
  49941. /**
  49942. * Gets the vector input component
  49943. */
  49944. readonly vector: NodeMaterialConnectionPoint;
  49945. protected _buildBlock(state: NodeMaterialBuildState): this;
  49946. }
  49947. }
  49948. declare module BABYLON {
  49949. /**
  49950. * Block used to add support for vertex skinning (bones)
  49951. */
  49952. export class BonesBlock extends NodeMaterialBlock {
  49953. /**
  49954. * Creates a new BonesBlock
  49955. * @param name defines the block name
  49956. */
  49957. constructor(name: string);
  49958. /**
  49959. * Initialize the block and prepare the context for build
  49960. * @param state defines the state that will be used for the build
  49961. */
  49962. initialize(state: NodeMaterialBuildState): void;
  49963. /**
  49964. * Gets the current class name
  49965. * @returns the class name
  49966. */
  49967. getClassName(): string;
  49968. /**
  49969. * Gets the matrix indices input component
  49970. */
  49971. readonly matricesIndices: NodeMaterialConnectionPoint;
  49972. /**
  49973. * Gets the matrix weights input component
  49974. */
  49975. readonly matricesWeights: NodeMaterialConnectionPoint;
  49976. /**
  49977. * Gets the extra matrix indices input component
  49978. */
  49979. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  49980. /**
  49981. * Gets the extra matrix weights input component
  49982. */
  49983. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  49984. /**
  49985. * Gets the world input component
  49986. */
  49987. readonly world: NodeMaterialConnectionPoint;
  49988. autoConfigure(): void;
  49989. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  49990. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  49991. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  49992. protected _buildBlock(state: NodeMaterialBuildState): this;
  49993. }
  49994. }
  49995. declare module BABYLON {
  49996. /**
  49997. * Block used to add support for instances
  49998. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  49999. */
  50000. export class InstancesBlock extends NodeMaterialBlock {
  50001. /**
  50002. * Creates a new InstancesBlock
  50003. * @param name defines the block name
  50004. */
  50005. constructor(name: string);
  50006. /**
  50007. * Gets the current class name
  50008. * @returns the class name
  50009. */
  50010. getClassName(): string;
  50011. /**
  50012. * Gets the first world row input component
  50013. */
  50014. readonly world0: NodeMaterialConnectionPoint;
  50015. /**
  50016. * Gets the second world row input component
  50017. */
  50018. readonly world1: NodeMaterialConnectionPoint;
  50019. /**
  50020. * Gets the third world row input component
  50021. */
  50022. readonly world2: NodeMaterialConnectionPoint;
  50023. /**
  50024. * Gets the forth world row input component
  50025. */
  50026. readonly world3: NodeMaterialConnectionPoint;
  50027. /**
  50028. * Gets the world input component
  50029. */
  50030. readonly world: NodeMaterialConnectionPoint;
  50031. /**
  50032. * Gets the output component
  50033. */
  50034. readonly output: NodeMaterialConnectionPoint;
  50035. autoConfigure(): void;
  50036. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  50037. protected _buildBlock(state: NodeMaterialBuildState): this;
  50038. }
  50039. }
  50040. declare module BABYLON {
  50041. /**
  50042. * Block used to add morph targets support to vertex shader
  50043. */
  50044. export class MorphTargetsBlock extends NodeMaterialBlock {
  50045. private _repeatableContentAnchor;
  50046. private _repeatebleContentGenerated;
  50047. /**
  50048. * Create a new MorphTargetsBlock
  50049. * @param name defines the block name
  50050. */
  50051. constructor(name: string);
  50052. /**
  50053. * Gets the current class name
  50054. * @returns the class name
  50055. */
  50056. getClassName(): string;
  50057. /**
  50058. * Gets the position input component
  50059. */
  50060. readonly position: NodeMaterialConnectionPoint;
  50061. /**
  50062. * Gets the normal input component
  50063. */
  50064. readonly normal: NodeMaterialConnectionPoint;
  50065. /**
  50066. * Gets the tangent input component
  50067. */
  50068. readonly tangent: NodeMaterialConnectionPoint;
  50069. /**
  50070. * Gets the position output component
  50071. */
  50072. readonly positionOutput: NodeMaterialConnectionPoint;
  50073. /**
  50074. * Gets the normal output component
  50075. */
  50076. readonly normalOutput: NodeMaterialConnectionPoint;
  50077. /**
  50078. * Gets the tangent output component
  50079. */
  50080. readonly tangentOutput: NodeMaterialConnectionPoint;
  50081. initialize(state: NodeMaterialBuildState): void;
  50082. autoConfigure(): void;
  50083. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50085. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  50086. protected _buildBlock(state: NodeMaterialBuildState): this;
  50087. }
  50088. }
  50089. declare module BABYLON {
  50090. /**
  50091. * Block used to output the final color
  50092. */
  50093. export class FragmentOutputBlock extends NodeMaterialBlock {
  50094. /**
  50095. * Gets or sets a boolean indicating if this block will output an alpha value
  50096. */
  50097. alphaBlendingEnabled: boolean;
  50098. /**
  50099. * Create a new FragmentOutputBlock
  50100. * @param name defines the block name
  50101. */
  50102. constructor(name: string);
  50103. /**
  50104. * Gets the current class name
  50105. * @returns the class name
  50106. */
  50107. getClassName(): string;
  50108. /**
  50109. * Gets the color input component
  50110. */
  50111. readonly color: NodeMaterialConnectionPoint;
  50112. protected _buildBlock(state: NodeMaterialBuildState): this;
  50113. }
  50114. }
  50115. declare module BABYLON {
  50116. /**
  50117. * Block used to add an alpha test in the fragment shader
  50118. */
  50119. export class AlphaTestBlock extends NodeMaterialBlock {
  50120. /**
  50121. * Gets or sets the alpha value where alpha testing happens
  50122. */
  50123. alphaCutOff: number;
  50124. /**
  50125. * Create a new AlphaTestBlock
  50126. * @param name defines the block name
  50127. */
  50128. constructor(name: string);
  50129. /**
  50130. * Gets the current class name
  50131. * @returns the class name
  50132. */
  50133. getClassName(): string;
  50134. /**
  50135. * Gets the color input component
  50136. */
  50137. readonly color: NodeMaterialConnectionPoint;
  50138. protected _buildBlock(state: NodeMaterialBuildState): this;
  50139. }
  50140. }
  50141. declare module BABYLON {
  50142. /**
  50143. * Block used to create a Color4 out of 4 inputs (one for each component)
  50144. */
  50145. export class RGBAMergerBlock extends NodeMaterialBlock {
  50146. /**
  50147. * Create a new RGBAMergerBlock
  50148. * @param name defines the block name
  50149. */
  50150. constructor(name: string);
  50151. /**
  50152. * Gets the current class name
  50153. * @returns the class name
  50154. */
  50155. getClassName(): string;
  50156. /**
  50157. * Gets the R input component
  50158. */
  50159. readonly r: NodeMaterialConnectionPoint;
  50160. /**
  50161. * Gets the G input component
  50162. */
  50163. readonly g: NodeMaterialConnectionPoint;
  50164. /**
  50165. * Gets the B input component
  50166. */
  50167. readonly b: NodeMaterialConnectionPoint;
  50168. /**
  50169. * Gets the RGB input component
  50170. */
  50171. readonly rgb: NodeMaterialConnectionPoint;
  50172. /**
  50173. * Gets the R input component
  50174. */
  50175. readonly a: NodeMaterialConnectionPoint;
  50176. protected _buildBlock(state: NodeMaterialBuildState): this;
  50177. }
  50178. }
  50179. declare module BABYLON {
  50180. /**
  50181. * Block used to create a Color3 out of 3 inputs (one for each component)
  50182. */
  50183. export class RGBMergerBlock extends NodeMaterialBlock {
  50184. /**
  50185. * Create a new RGBMergerBlock
  50186. * @param name defines the block name
  50187. */
  50188. constructor(name: string);
  50189. /**
  50190. * Gets the current class name
  50191. * @returns the class name
  50192. */
  50193. getClassName(): string;
  50194. /**
  50195. * Gets the R component input
  50196. */
  50197. readonly r: NodeMaterialConnectionPoint;
  50198. /**
  50199. * Gets the G component input
  50200. */
  50201. readonly g: NodeMaterialConnectionPoint;
  50202. /**
  50203. * Gets the B component input
  50204. */
  50205. readonly b: NodeMaterialConnectionPoint;
  50206. protected _buildBlock(state: NodeMaterialBuildState): this;
  50207. }
  50208. }
  50209. declare module BABYLON {
  50210. /**
  50211. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  50212. */
  50213. export class RGBASplitterBlock extends NodeMaterialBlock {
  50214. /**
  50215. * Create a new RGBASplitterBlock
  50216. * @param name defines the block name
  50217. */
  50218. constructor(name: string);
  50219. /**
  50220. * Gets the current class name
  50221. * @returns the class name
  50222. */
  50223. getClassName(): string;
  50224. /**
  50225. * Gets the input component
  50226. */
  50227. readonly input: NodeMaterialConnectionPoint;
  50228. protected _buildBlock(state: NodeMaterialBuildState): this;
  50229. }
  50230. }
  50231. declare module BABYLON {
  50232. /**
  50233. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  50234. */
  50235. export class RGBSplitterBlock extends NodeMaterialBlock {
  50236. /**
  50237. * Create a new RGBSplitterBlock
  50238. * @param name defines the block name
  50239. */
  50240. constructor(name: string);
  50241. /**
  50242. * Gets the current class name
  50243. * @returns the class name
  50244. */
  50245. getClassName(): string;
  50246. /**
  50247. * Gets the input component
  50248. */
  50249. readonly input: NodeMaterialConnectionPoint;
  50250. protected _buildBlock(state: NodeMaterialBuildState): this;
  50251. }
  50252. }
  50253. declare module BABYLON {
  50254. /**
  50255. * Block used to read a texture from a sampler
  50256. */
  50257. export class TextureBlock extends NodeMaterialBlock {
  50258. private _defineName;
  50259. /**
  50260. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  50261. */
  50262. autoConnectTextureMatrix: boolean;
  50263. /**
  50264. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  50265. */
  50266. autoSelectUV: boolean;
  50267. /**
  50268. * Create a new TextureBlock
  50269. * @param name defines the block name
  50270. */
  50271. constructor(name: string);
  50272. /**
  50273. * Gets the current class name
  50274. * @returns the class name
  50275. */
  50276. getClassName(): string;
  50277. /**
  50278. * Gets the uv input component
  50279. */
  50280. readonly uv: NodeMaterialConnectionPoint;
  50281. /**
  50282. * Gets the texture information input component
  50283. */
  50284. readonly textureInfo: NodeMaterialConnectionPoint;
  50285. /**
  50286. * Gets the transformed uv input component
  50287. */
  50288. readonly transformedUV: NodeMaterialConnectionPoint;
  50289. /**
  50290. * Gets the texture input component
  50291. */
  50292. readonly texture: NodeMaterialConnectionPoint;
  50293. /**
  50294. * Gets the texture transform input component
  50295. */
  50296. readonly textureTransform: NodeMaterialConnectionPoint;
  50297. autoConfigure(): void;
  50298. initialize(state: NodeMaterialBuildState): void;
  50299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50300. isReady(): boolean;
  50301. private _injectVertexCode;
  50302. protected _buildBlock(state: NodeMaterialBuildState): this;
  50303. }
  50304. }
  50305. declare module BABYLON {
  50306. /**
  50307. * Block used to add image processing support to fragment shader
  50308. */
  50309. export class ImageProcessingBlock extends NodeMaterialBlock {
  50310. /**
  50311. * Create a new ImageProcessingBlock
  50312. * @param name defines the block name
  50313. */
  50314. constructor(name: string);
  50315. /**
  50316. * Gets the current class name
  50317. * @returns the class name
  50318. */
  50319. getClassName(): string;
  50320. /**
  50321. * Gets the color input component
  50322. */
  50323. readonly color: NodeMaterialConnectionPoint;
  50324. /**
  50325. * Initialize the block and prepare the context for build
  50326. * @param state defines the state that will be used for the build
  50327. */
  50328. initialize(state: NodeMaterialBuildState): void;
  50329. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  50330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50331. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50332. protected _buildBlock(state: NodeMaterialBuildState): this;
  50333. }
  50334. }
  50335. declare module BABYLON {
  50336. /**
  50337. * Block used to add support for scene fog
  50338. */
  50339. export class FogBlock extends NodeMaterialBlock {
  50340. /**
  50341. * Create a new FogBlock
  50342. * @param name defines the block name
  50343. */
  50344. constructor(name: string);
  50345. /**
  50346. * Gets the current class name
  50347. * @returns the class name
  50348. */
  50349. getClassName(): string;
  50350. /**
  50351. * Gets the world position input component
  50352. */
  50353. readonly worldPosition: NodeMaterialConnectionPoint;
  50354. /**
  50355. * Gets the view input component
  50356. */
  50357. readonly view: NodeMaterialConnectionPoint;
  50358. /**
  50359. * Gets the color input component
  50360. */
  50361. readonly color: NodeMaterialConnectionPoint;
  50362. /**
  50363. * Gets the fog color input component
  50364. */
  50365. readonly fogColor: NodeMaterialConnectionPoint;
  50366. /**
  50367. * Gets the for parameter input component
  50368. */
  50369. readonly fogParameters: NodeMaterialConnectionPoint;
  50370. autoConfigure(): void;
  50371. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  50372. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  50373. protected _buildBlock(state: NodeMaterialBuildState): this;
  50374. }
  50375. }
  50376. declare module BABYLON {
  50377. /**
  50378. * Block used to multiply 2 vector4
  50379. */
  50380. export class MultiplyBlock extends NodeMaterialBlock {
  50381. /**
  50382. * Creates a new MultiplyBlock
  50383. * @param name defines the block name
  50384. */
  50385. constructor(name: string);
  50386. /**
  50387. * Gets the current class name
  50388. * @returns the class name
  50389. */
  50390. getClassName(): string;
  50391. /**
  50392. * Gets the left operand input component
  50393. */
  50394. readonly left: NodeMaterialConnectionPoint;
  50395. /**
  50396. * Gets the right operand input component
  50397. */
  50398. readonly right: NodeMaterialConnectionPoint;
  50399. protected _buildBlock(state: NodeMaterialBuildState): this;
  50400. }
  50401. }
  50402. declare module BABYLON {
  50403. /**
  50404. * Block used to add 2 vector4
  50405. */
  50406. export class AddBlock extends NodeMaterialBlock {
  50407. /**
  50408. * Creates a new AddBlock
  50409. * @param name defines the block name
  50410. */
  50411. constructor(name: string);
  50412. /**
  50413. * Gets the current class name
  50414. * @returns the class name
  50415. */
  50416. getClassName(): string;
  50417. /**
  50418. * Gets the left operand input component
  50419. */
  50420. readonly left: NodeMaterialConnectionPoint;
  50421. /**
  50422. * Gets the right operand input component
  50423. */
  50424. readonly right: NodeMaterialConnectionPoint;
  50425. protected _buildBlock(state: NodeMaterialBuildState): this;
  50426. }
  50427. }
  50428. declare module BABYLON {
  50429. /**
  50430. * Block used to clamp a float
  50431. */
  50432. export class ClampBlock extends NodeMaterialBlock {
  50433. /** Gets or sets the minimum range */
  50434. minimum: number;
  50435. /** Gets or sets the maximum range */
  50436. maximum: number;
  50437. /**
  50438. * Creates a new ClampBlock
  50439. * @param name defines the block name
  50440. */
  50441. constructor(name: string);
  50442. /**
  50443. * Gets the current class name
  50444. * @returns the class name
  50445. */
  50446. getClassName(): string;
  50447. /**
  50448. * Gets the value input component
  50449. */
  50450. readonly value: NodeMaterialConnectionPoint;
  50451. protected _buildBlock(state: NodeMaterialBuildState): this;
  50452. }
  50453. }
  50454. declare module BABYLON {
  50455. /**
  50456. * Block used to transform a vector2 with a matrix
  50457. */
  50458. export class Vector2TransformBlock extends NodeMaterialBlock {
  50459. /**
  50460. * Defines the value to use to complement Vector2 to transform it to a Vector4
  50461. */
  50462. complementZ: number;
  50463. /**
  50464. * Defines the value to use to complement Vector2 to transform it to a Vector4
  50465. */
  50466. complementW: number;
  50467. /**
  50468. * Creates a new Vector2TransformBlock
  50469. * @param name defines the block name
  50470. */
  50471. constructor(name: string);
  50472. /**
  50473. * Gets the vector input
  50474. */
  50475. readonly vector: NodeMaterialConnectionPoint;
  50476. /**
  50477. * Gets the matrix transform input
  50478. */
  50479. readonly transform: NodeMaterialConnectionPoint;
  50480. /**
  50481. * Gets the current class name
  50482. * @returns the class name
  50483. */
  50484. getClassName(): string;
  50485. protected _buildBlock(state: NodeMaterialBuildState): this;
  50486. }
  50487. }
  50488. declare module BABYLON {
  50489. /**
  50490. * Block used to transform a vector3 with a matrix
  50491. */
  50492. export class Vector3TransformBlock extends NodeMaterialBlock {
  50493. /**
  50494. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50495. */
  50496. complement: number;
  50497. /**
  50498. * Creates a new Vector3TransformBlock
  50499. * @param name defines the block name
  50500. */
  50501. constructor(name: string);
  50502. /**
  50503. * Gets the vector input
  50504. */
  50505. readonly vector: NodeMaterialConnectionPoint;
  50506. /**
  50507. * Gets the matrix transform input
  50508. */
  50509. readonly transform: NodeMaterialConnectionPoint;
  50510. /**
  50511. * Gets the current class name
  50512. * @returns the class name
  50513. */
  50514. getClassName(): string;
  50515. protected _buildBlock(state: NodeMaterialBuildState): this;
  50516. }
  50517. }
  50518. declare module BABYLON {
  50519. /**
  50520. * Block used to transform a vector4 with a matrix
  50521. */
  50522. export class Vector4TransformBlock extends NodeMaterialBlock {
  50523. /**
  50524. * Defines the value to use to complement Vector3 to transform it to a Vector4
  50525. */
  50526. complementW: number;
  50527. /**
  50528. * Creates a new Vector4TransformBlock
  50529. * @param name defines the block name
  50530. */
  50531. constructor(name: string);
  50532. /**
  50533. * Gets the current class name
  50534. * @returns the class name
  50535. */
  50536. getClassName(): string;
  50537. /**
  50538. * Gets the vector input
  50539. */
  50540. readonly vector: NodeMaterialConnectionPoint;
  50541. /**
  50542. * Gets the matrix transform input
  50543. */
  50544. readonly transform: NodeMaterialConnectionPoint;
  50545. protected _buildBlock(state: NodeMaterialBuildState): this;
  50546. }
  50547. }
  50548. declare module BABYLON {
  50549. /**
  50550. * Block used to multiply two matrices
  50551. */
  50552. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  50553. /**
  50554. * Creates a new MatrixMultiplicationBlock
  50555. * @param name defines the block name
  50556. */
  50557. constructor(name: string);
  50558. /**
  50559. * Gets the left operand
  50560. */
  50561. readonly left: NodeMaterialConnectionPoint;
  50562. /**
  50563. * Gets the right operand
  50564. */
  50565. readonly right: NodeMaterialConnectionPoint;
  50566. /**
  50567. * Gets the current class name
  50568. * @returns the class name
  50569. */
  50570. getClassName(): string;
  50571. protected _buildBlock(state: NodeMaterialBuildState): this;
  50572. }
  50573. }
  50574. declare module BABYLON {
  50575. /**
  50576. * Helper class to push actions to a pool of workers.
  50577. */
  50578. export class WorkerPool implements IDisposable {
  50579. private _workerInfos;
  50580. private _pendingActions;
  50581. /**
  50582. * Constructor
  50583. * @param workers Array of workers to use for actions
  50584. */
  50585. constructor(workers: Array<Worker>);
  50586. /**
  50587. * Terminates all workers and clears any pending actions.
  50588. */
  50589. dispose(): void;
  50590. /**
  50591. * Pushes an action to the worker pool. If all the workers are active, the action will be
  50592. * pended until a worker has completed its action.
  50593. * @param action The action to perform. Call onComplete when the action is complete.
  50594. */
  50595. push(action: (worker: Worker, onComplete: () => void) => void): void;
  50596. private _execute;
  50597. }
  50598. }
  50599. declare module BABYLON {
  50600. /**
  50601. * Configuration for Draco compression
  50602. */
  50603. export interface IDracoCompressionConfiguration {
  50604. /**
  50605. * Configuration for the decoder.
  50606. */
  50607. decoder: {
  50608. /**
  50609. * The url to the WebAssembly module.
  50610. */
  50611. wasmUrl?: string;
  50612. /**
  50613. * The url to the WebAssembly binary.
  50614. */
  50615. wasmBinaryUrl?: string;
  50616. /**
  50617. * The url to the fallback JavaScript module.
  50618. */
  50619. fallbackUrl?: string;
  50620. };
  50621. }
  50622. /**
  50623. * Draco compression (https://google.github.io/draco/)
  50624. *
  50625. * This class wraps the Draco module.
  50626. *
  50627. * **Encoder**
  50628. *
  50629. * The encoder is not currently implemented.
  50630. *
  50631. * **Decoder**
  50632. *
  50633. * 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.
  50634. *
  50635. * To update the configuration, use the following code:
  50636. * ```javascript
  50637. * DracoCompression.Configuration = {
  50638. * decoder: {
  50639. * wasmUrl: "<url to the WebAssembly library>",
  50640. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  50641. * fallbackUrl: "<url to the fallback JavaScript library>",
  50642. * }
  50643. * };
  50644. * ```
  50645. *
  50646. * 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.
  50647. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  50648. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  50649. *
  50650. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  50651. * ```javascript
  50652. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  50653. * ```
  50654. *
  50655. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  50656. */
  50657. export class DracoCompression implements IDisposable {
  50658. private _workerPoolPromise?;
  50659. private _decoderModulePromise?;
  50660. /**
  50661. * The configuration. Defaults to the following urls:
  50662. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  50663. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  50664. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  50665. */
  50666. static Configuration: IDracoCompressionConfiguration;
  50667. /**
  50668. * Returns true if the decoder configuration is available.
  50669. */
  50670. static readonly DecoderAvailable: boolean;
  50671. /**
  50672. * Default number of workers to create when creating the draco compression object.
  50673. */
  50674. static DefaultNumWorkers: number;
  50675. private static GetDefaultNumWorkers;
  50676. private static _Default;
  50677. /**
  50678. * Default instance for the draco compression object.
  50679. */
  50680. static readonly Default: DracoCompression;
  50681. /**
  50682. * Constructor
  50683. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  50684. */
  50685. constructor(numWorkers?: number);
  50686. /**
  50687. * Stop all async operations and release resources.
  50688. */
  50689. dispose(): void;
  50690. /**
  50691. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  50692. * @returns a promise that resolves when ready
  50693. */
  50694. whenReadyAsync(): Promise<void>;
  50695. /**
  50696. * Decode Draco compressed mesh data to vertex data.
  50697. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  50698. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  50699. * @returns A promise that resolves with the decoded vertex data
  50700. */
  50701. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  50702. [kind: string]: number;
  50703. }): Promise<VertexData>;
  50704. }
  50705. }
  50706. declare module BABYLON {
  50707. /**
  50708. * Class for building Constructive Solid Geometry
  50709. */
  50710. export class CSG {
  50711. private polygons;
  50712. /**
  50713. * The world matrix
  50714. */
  50715. matrix: Matrix;
  50716. /**
  50717. * Stores the position
  50718. */
  50719. position: Vector3;
  50720. /**
  50721. * Stores the rotation
  50722. */
  50723. rotation: Vector3;
  50724. /**
  50725. * Stores the rotation quaternion
  50726. */
  50727. rotationQuaternion: Nullable<Quaternion>;
  50728. /**
  50729. * Stores the scaling vector
  50730. */
  50731. scaling: Vector3;
  50732. /**
  50733. * Convert the Mesh to CSG
  50734. * @param mesh The Mesh to convert to CSG
  50735. * @returns A new CSG from the Mesh
  50736. */
  50737. static FromMesh(mesh: Mesh): CSG;
  50738. /**
  50739. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  50740. * @param polygons Polygons used to construct a CSG solid
  50741. */
  50742. private static FromPolygons;
  50743. /**
  50744. * Clones, or makes a deep copy, of the CSG
  50745. * @returns A new CSG
  50746. */
  50747. clone(): CSG;
  50748. /**
  50749. * Unions this CSG with another CSG
  50750. * @param csg The CSG to union against this CSG
  50751. * @returns The unioned CSG
  50752. */
  50753. union(csg: CSG): CSG;
  50754. /**
  50755. * Unions this CSG with another CSG in place
  50756. * @param csg The CSG to union against this CSG
  50757. */
  50758. unionInPlace(csg: CSG): void;
  50759. /**
  50760. * Subtracts this CSG with another CSG
  50761. * @param csg The CSG to subtract against this CSG
  50762. * @returns A new CSG
  50763. */
  50764. subtract(csg: CSG): CSG;
  50765. /**
  50766. * Subtracts this CSG with another CSG in place
  50767. * @param csg The CSG to subtact against this CSG
  50768. */
  50769. subtractInPlace(csg: CSG): void;
  50770. /**
  50771. * Intersect this CSG with another CSG
  50772. * @param csg The CSG to intersect against this CSG
  50773. * @returns A new CSG
  50774. */
  50775. intersect(csg: CSG): CSG;
  50776. /**
  50777. * Intersects this CSG with another CSG in place
  50778. * @param csg The CSG to intersect against this CSG
  50779. */
  50780. intersectInPlace(csg: CSG): void;
  50781. /**
  50782. * Return a new CSG solid with solid and empty space switched. This solid is
  50783. * not modified.
  50784. * @returns A new CSG solid with solid and empty space switched
  50785. */
  50786. inverse(): CSG;
  50787. /**
  50788. * Inverses the CSG in place
  50789. */
  50790. inverseInPlace(): void;
  50791. /**
  50792. * This is used to keep meshes transformations so they can be restored
  50793. * when we build back a Babylon Mesh
  50794. * NB : All CSG operations are performed in world coordinates
  50795. * @param csg The CSG to copy the transform attributes from
  50796. * @returns This CSG
  50797. */
  50798. copyTransformAttributes(csg: CSG): CSG;
  50799. /**
  50800. * Build Raw mesh from CSG
  50801. * Coordinates here are in world space
  50802. * @param name The name of the mesh geometry
  50803. * @param scene The Scene
  50804. * @param keepSubMeshes Specifies if the submeshes should be kept
  50805. * @returns A new Mesh
  50806. */
  50807. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  50808. /**
  50809. * Build Mesh from CSG taking material and transforms into account
  50810. * @param name The name of the Mesh
  50811. * @param material The material of the Mesh
  50812. * @param scene The Scene
  50813. * @param keepSubMeshes Specifies if submeshes should be kept
  50814. * @returns The new Mesh
  50815. */
  50816. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  50817. }
  50818. }
  50819. declare module BABYLON {
  50820. /**
  50821. * Class used to create a trail following a mesh
  50822. */
  50823. export class TrailMesh extends Mesh {
  50824. private _generator;
  50825. private _autoStart;
  50826. private _running;
  50827. private _diameter;
  50828. private _length;
  50829. private _sectionPolygonPointsCount;
  50830. private _sectionVectors;
  50831. private _sectionNormalVectors;
  50832. private _beforeRenderObserver;
  50833. /**
  50834. * @constructor
  50835. * @param name The value used by scene.getMeshByName() to do a lookup.
  50836. * @param generator The mesh to generate a trail.
  50837. * @param scene The scene to add this mesh to.
  50838. * @param diameter Diameter of trailing mesh. Default is 1.
  50839. * @param length Length of trailing mesh. Default is 60.
  50840. * @param autoStart Automatically start trailing mesh. Default true.
  50841. */
  50842. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  50843. /**
  50844. * "TrailMesh"
  50845. * @returns "TrailMesh"
  50846. */
  50847. getClassName(): string;
  50848. private _createMesh;
  50849. /**
  50850. * Start trailing mesh.
  50851. */
  50852. start(): void;
  50853. /**
  50854. * Stop trailing mesh.
  50855. */
  50856. stop(): void;
  50857. /**
  50858. * Update trailing mesh geometry.
  50859. */
  50860. update(): void;
  50861. /**
  50862. * Returns a new TrailMesh object.
  50863. * @param name is a string, the name given to the new mesh
  50864. * @param newGenerator use new generator object for cloned trail mesh
  50865. * @returns a new mesh
  50866. */
  50867. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  50868. /**
  50869. * Serializes this trail mesh
  50870. * @param serializationObject object to write serialization to
  50871. */
  50872. serialize(serializationObject: any): void;
  50873. /**
  50874. * Parses a serialized trail mesh
  50875. * @param parsedMesh the serialized mesh
  50876. * @param scene the scene to create the trail mesh in
  50877. * @returns the created trail mesh
  50878. */
  50879. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  50880. }
  50881. }
  50882. declare module BABYLON {
  50883. /**
  50884. * Class containing static functions to help procedurally build meshes
  50885. */
  50886. export class TiledBoxBuilder {
  50887. /**
  50888. * Creates a box mesh
  50889. * faceTiles sets the pattern, tile size and number of tiles for a face * * You can set different colors and different images to each box side by using the parameters `faceColors` (an array of 6 Color3 elements) and `faceUV` (an array of 6 Vector4 elements)
  50890. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  50891. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50892. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50893. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50894. * @param name defines the name of the mesh
  50895. * @param options defines the options used to create the mesh
  50896. * @param scene defines the hosting scene
  50897. * @returns the box mesh
  50898. */
  50899. static CreateTiledBox(name: string, options: {
  50900. pattern?: number;
  50901. width?: number;
  50902. height?: number;
  50903. depth?: number;
  50904. tileSize?: number;
  50905. tileWidth?: number;
  50906. tileHeight?: number;
  50907. alignHorizontal?: number;
  50908. alignVertical?: number;
  50909. faceUV?: Vector4[];
  50910. faceColors?: Color4[];
  50911. sideOrientation?: number;
  50912. updatable?: boolean;
  50913. }, scene?: Nullable<Scene>): Mesh;
  50914. }
  50915. }
  50916. declare module BABYLON {
  50917. /**
  50918. * Class containing static functions to help procedurally build meshes
  50919. */
  50920. export class TorusKnotBuilder {
  50921. /**
  50922. * Creates a torus knot mesh
  50923. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  50924. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  50925. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  50926. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  50927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50930. * @param name defines the name of the mesh
  50931. * @param options defines the options used to create the mesh
  50932. * @param scene defines the hosting scene
  50933. * @returns the torus knot mesh
  50934. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  50935. */
  50936. static CreateTorusKnot(name: string, options: {
  50937. radius?: number;
  50938. tube?: number;
  50939. radialSegments?: number;
  50940. tubularSegments?: number;
  50941. p?: number;
  50942. q?: number;
  50943. updatable?: boolean;
  50944. sideOrientation?: number;
  50945. frontUVs?: Vector4;
  50946. backUVs?: Vector4;
  50947. }, scene: any): Mesh;
  50948. }
  50949. }
  50950. declare module BABYLON {
  50951. /**
  50952. * Polygon
  50953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  50954. */
  50955. export class Polygon {
  50956. /**
  50957. * Creates a rectangle
  50958. * @param xmin bottom X coord
  50959. * @param ymin bottom Y coord
  50960. * @param xmax top X coord
  50961. * @param ymax top Y coord
  50962. * @returns points that make the resulting rectation
  50963. */
  50964. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  50965. /**
  50966. * Creates a circle
  50967. * @param radius radius of circle
  50968. * @param cx scale in x
  50969. * @param cy scale in y
  50970. * @param numberOfSides number of sides that make up the circle
  50971. * @returns points that make the resulting circle
  50972. */
  50973. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  50974. /**
  50975. * Creates a polygon from input string
  50976. * @param input Input polygon data
  50977. * @returns the parsed points
  50978. */
  50979. static Parse(input: string): Vector2[];
  50980. /**
  50981. * Starts building a polygon from x and y coordinates
  50982. * @param x x coordinate
  50983. * @param y y coordinate
  50984. * @returns the started path2
  50985. */
  50986. static StartingAt(x: number, y: number): Path2;
  50987. }
  50988. /**
  50989. * Builds a polygon
  50990. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  50991. */
  50992. export class PolygonMeshBuilder {
  50993. private _points;
  50994. private _outlinepoints;
  50995. private _holes;
  50996. private _name;
  50997. private _scene;
  50998. private _epoints;
  50999. private _eholes;
  51000. private _addToepoint;
  51001. /**
  51002. * Babylon reference to the earcut plugin.
  51003. */
  51004. bjsEarcut: any;
  51005. /**
  51006. * Creates a PolygonMeshBuilder
  51007. * @param name name of the builder
  51008. * @param contours Path of the polygon
  51009. * @param scene scene to add to when creating the mesh
  51010. * @param earcutInjection can be used to inject your own earcut reference
  51011. */
  51012. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51013. /**
  51014. * Adds a whole within the polygon
  51015. * @param hole Array of points defining the hole
  51016. * @returns this
  51017. */
  51018. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51019. /**
  51020. * Creates the polygon
  51021. * @param updatable If the mesh should be updatable
  51022. * @param depth The depth of the mesh created
  51023. * @returns the created mesh
  51024. */
  51025. build(updatable?: boolean, depth?: number): Mesh;
  51026. /**
  51027. * Creates the polygon
  51028. * @param depth The depth of the mesh created
  51029. * @returns the created VertexData
  51030. */
  51031. buildVertexData(depth?: number): VertexData;
  51032. /**
  51033. * Adds a side to the polygon
  51034. * @param positions points that make the polygon
  51035. * @param normals normals of the polygon
  51036. * @param uvs uvs of the polygon
  51037. * @param indices indices of the polygon
  51038. * @param bounds bounds of the polygon
  51039. * @param points points of the polygon
  51040. * @param depth depth of the polygon
  51041. * @param flip flip of the polygon
  51042. */
  51043. private addSide;
  51044. }
  51045. }
  51046. declare module BABYLON {
  51047. /**
  51048. * Class containing static functions to help procedurally build meshes
  51049. */
  51050. export class PolygonBuilder {
  51051. /**
  51052. * Creates a polygon mesh
  51053. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51054. * * 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
  51055. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51057. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51058. * * Remember you can only change the shape positions, not their number when updating a polygon
  51059. * @param name defines the name of the mesh
  51060. * @param options defines the options used to create the mesh
  51061. * @param scene defines the hosting scene
  51062. * @param earcutInjection can be used to inject your own earcut reference
  51063. * @returns the polygon mesh
  51064. */
  51065. static CreatePolygon(name: string, options: {
  51066. shape: Vector3[];
  51067. holes?: Vector3[][];
  51068. depth?: number;
  51069. faceUV?: Vector4[];
  51070. faceColors?: Color4[];
  51071. updatable?: boolean;
  51072. sideOrientation?: number;
  51073. frontUVs?: Vector4;
  51074. backUVs?: Vector4;
  51075. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51076. /**
  51077. * Creates an extruded polygon mesh, with depth in the Y direction.
  51078. * * 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)
  51079. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51080. * @param name defines the name of the mesh
  51081. * @param options defines the options used to create the mesh
  51082. * @param scene defines the hosting scene
  51083. * @param earcutInjection can be used to inject your own earcut reference
  51084. * @returns the polygon mesh
  51085. */
  51086. static ExtrudePolygon(name: string, options: {
  51087. shape: Vector3[];
  51088. holes?: Vector3[][];
  51089. depth?: number;
  51090. faceUV?: Vector4[];
  51091. faceColors?: Color4[];
  51092. updatable?: boolean;
  51093. sideOrientation?: number;
  51094. frontUVs?: Vector4;
  51095. backUVs?: Vector4;
  51096. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51097. }
  51098. }
  51099. declare module BABYLON {
  51100. /**
  51101. * Class containing static functions to help procedurally build meshes
  51102. */
  51103. export class LatheBuilder {
  51104. /**
  51105. * Creates lathe mesh.
  51106. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51107. * * 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
  51108. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51109. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51110. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51111. * * 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
  51112. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51113. * * 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
  51114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51116. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51118. * @param name defines the name of the mesh
  51119. * @param options defines the options used to create the mesh
  51120. * @param scene defines the hosting scene
  51121. * @returns the lathe mesh
  51122. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51123. */
  51124. static CreateLathe(name: string, options: {
  51125. shape: Vector3[];
  51126. radius?: number;
  51127. tessellation?: number;
  51128. clip?: number;
  51129. arc?: number;
  51130. closed?: boolean;
  51131. updatable?: boolean;
  51132. sideOrientation?: number;
  51133. frontUVs?: Vector4;
  51134. backUVs?: Vector4;
  51135. cap?: number;
  51136. invertUV?: boolean;
  51137. }, scene?: Nullable<Scene>): Mesh;
  51138. }
  51139. }
  51140. declare module BABYLON {
  51141. /**
  51142. * Class containing static functions to help procedurally build meshes
  51143. */
  51144. export class TiledPlaneBuilder {
  51145. /**
  51146. * Creates a tiled plane mesh
  51147. * * The parameter `pattern` will, depending on value, do nothing or
  51148. * * * flip (reflect about central vertical) alternate tiles across and up
  51149. * * * flip every tile on alternate rows
  51150. * * * rotate (180 degs) alternate tiles across and up
  51151. * * * rotate every tile on alternate rows
  51152. * * * flip and rotate alternate tiles across and up
  51153. * * * flip and rotate every tile on alternate rows
  51154. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  51155. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  51156. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51157. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51158. * * 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)
  51159. * * 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)
  51160. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51161. * @param name defines the name of the mesh
  51162. * @param options defines the options used to create the mesh
  51163. * @param scene defines the hosting scene
  51164. * @returns the box mesh
  51165. */
  51166. static CreateTiledPlane(name: string, options: {
  51167. pattern?: number;
  51168. tileSize?: number;
  51169. tileWidth?: number;
  51170. tileHeight?: number;
  51171. size?: number;
  51172. width?: number;
  51173. height?: number;
  51174. alignHorizontal?: number;
  51175. alignVertical?: number;
  51176. sideOrientation?: number;
  51177. frontUVs?: Vector4;
  51178. backUVs?: Vector4;
  51179. updatable?: boolean;
  51180. }, scene?: Nullable<Scene>): Mesh;
  51181. }
  51182. }
  51183. declare module BABYLON {
  51184. /**
  51185. * Class containing static functions to help procedurally build meshes
  51186. */
  51187. export class TubeBuilder {
  51188. /**
  51189. * Creates a tube mesh.
  51190. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51191. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51192. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51193. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51194. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51195. * * 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)
  51196. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51197. * * 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
  51198. * * 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
  51199. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51200. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51201. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51202. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51203. * @param name defines the name of the mesh
  51204. * @param options defines the options used to create the mesh
  51205. * @param scene defines the hosting scene
  51206. * @returns the tube mesh
  51207. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51208. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51209. */
  51210. static CreateTube(name: string, options: {
  51211. path: Vector3[];
  51212. radius?: number;
  51213. tessellation?: number;
  51214. radiusFunction?: {
  51215. (i: number, distance: number): number;
  51216. };
  51217. cap?: number;
  51218. arc?: number;
  51219. updatable?: boolean;
  51220. sideOrientation?: number;
  51221. frontUVs?: Vector4;
  51222. backUVs?: Vector4;
  51223. instance?: Mesh;
  51224. invertUV?: boolean;
  51225. }, scene?: Nullable<Scene>): Mesh;
  51226. }
  51227. }
  51228. declare module BABYLON {
  51229. /**
  51230. * Class containing static functions to help procedurally build meshes
  51231. */
  51232. export class IcoSphereBuilder {
  51233. /**
  51234. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51235. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51236. * * 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`)
  51237. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51238. * * 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
  51239. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51240. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51241. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51242. * @param name defines the name of the mesh
  51243. * @param options defines the options used to create the mesh
  51244. * @param scene defines the hosting scene
  51245. * @returns the icosahedron mesh
  51246. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51247. */
  51248. static CreateIcoSphere(name: string, options: {
  51249. radius?: number;
  51250. radiusX?: number;
  51251. radiusY?: number;
  51252. radiusZ?: number;
  51253. flat?: boolean;
  51254. subdivisions?: number;
  51255. sideOrientation?: number;
  51256. frontUVs?: Vector4;
  51257. backUVs?: Vector4;
  51258. updatable?: boolean;
  51259. }, scene?: Nullable<Scene>): Mesh;
  51260. }
  51261. }
  51262. declare module BABYLON {
  51263. /**
  51264. * Class containing static functions to help procedurally build meshes
  51265. */
  51266. export class DecalBuilder {
  51267. /**
  51268. * Creates a decal mesh.
  51269. * 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
  51270. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51271. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51272. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51273. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51274. * @param name defines the name of the mesh
  51275. * @param sourceMesh defines the mesh where the decal must be applied
  51276. * @param options defines the options used to create the mesh
  51277. * @param scene defines the hosting scene
  51278. * @returns the decal mesh
  51279. * @see https://doc.babylonjs.com/how_to/decals
  51280. */
  51281. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51282. position?: Vector3;
  51283. normal?: Vector3;
  51284. size?: Vector3;
  51285. angle?: number;
  51286. }): Mesh;
  51287. }
  51288. }
  51289. declare module BABYLON {
  51290. /**
  51291. * Class containing static functions to help procedurally build meshes
  51292. */
  51293. export class MeshBuilder {
  51294. /**
  51295. * Creates a box mesh
  51296. * * The parameter `size` sets the size (float) of each box side (default 1)
  51297. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51298. * * 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)
  51299. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51300. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51301. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51302. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51303. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51304. * @param name defines the name of the mesh
  51305. * @param options defines the options used to create the mesh
  51306. * @param scene defines the hosting scene
  51307. * @returns the box mesh
  51308. */
  51309. static CreateBox(name: string, options: {
  51310. size?: number;
  51311. width?: number;
  51312. height?: number;
  51313. depth?: number;
  51314. faceUV?: Vector4[];
  51315. faceColors?: Color4[];
  51316. sideOrientation?: number;
  51317. frontUVs?: Vector4;
  51318. backUVs?: Vector4;
  51319. updatable?: boolean;
  51320. }, scene?: Nullable<Scene>): Mesh;
  51321. /**
  51322. * Creates a tiled box mesh
  51323. * * faceTiles sets the pattern, tile size and number of tiles for a face
  51324. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51325. * @param name defines the name of the mesh
  51326. * @param options defines the options used to create the mesh
  51327. * @param scene defines the hosting scene
  51328. * @returns the tiled box mesh
  51329. */
  51330. static CreateTiledBox(name: string, options: {
  51331. pattern?: number;
  51332. size?: number;
  51333. width?: number;
  51334. height?: number;
  51335. depth: number;
  51336. tileSize?: number;
  51337. tileWidth?: number;
  51338. tileHeight?: number;
  51339. faceUV?: Vector4[];
  51340. faceColors?: Color4[];
  51341. alignHorizontal?: number;
  51342. alignVertical?: number;
  51343. sideOrientation?: number;
  51344. updatable?: boolean;
  51345. }, scene?: Nullable<Scene>): Mesh;
  51346. /**
  51347. * Creates a sphere mesh
  51348. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51349. * * 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`)
  51350. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51351. * * 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
  51352. * * 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)
  51353. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51354. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51355. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51356. * @param name defines the name of the mesh
  51357. * @param options defines the options used to create the mesh
  51358. * @param scene defines the hosting scene
  51359. * @returns the sphere mesh
  51360. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51361. */
  51362. static CreateSphere(name: string, options: {
  51363. segments?: number;
  51364. diameter?: number;
  51365. diameterX?: number;
  51366. diameterY?: number;
  51367. diameterZ?: number;
  51368. arc?: number;
  51369. slice?: number;
  51370. sideOrientation?: number;
  51371. frontUVs?: Vector4;
  51372. backUVs?: Vector4;
  51373. updatable?: boolean;
  51374. }, scene?: Nullable<Scene>): Mesh;
  51375. /**
  51376. * Creates a plane polygonal mesh. By default, this is a disc
  51377. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  51378. * * 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
  51379. * * 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
  51380. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51381. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51383. * @param name defines the name of the mesh
  51384. * @param options defines the options used to create the mesh
  51385. * @param scene defines the hosting scene
  51386. * @returns the plane polygonal mesh
  51387. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  51388. */
  51389. static CreateDisc(name: string, options: {
  51390. radius?: number;
  51391. tessellation?: number;
  51392. arc?: number;
  51393. updatable?: boolean;
  51394. sideOrientation?: number;
  51395. frontUVs?: Vector4;
  51396. backUVs?: Vector4;
  51397. }, scene?: Nullable<Scene>): Mesh;
  51398. /**
  51399. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  51400. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  51401. * * 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`)
  51402. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  51403. * * 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
  51404. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51405. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51407. * @param name defines the name of the mesh
  51408. * @param options defines the options used to create the mesh
  51409. * @param scene defines the hosting scene
  51410. * @returns the icosahedron mesh
  51411. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  51412. */
  51413. static CreateIcoSphere(name: string, options: {
  51414. radius?: number;
  51415. radiusX?: number;
  51416. radiusY?: number;
  51417. radiusZ?: number;
  51418. flat?: boolean;
  51419. subdivisions?: number;
  51420. sideOrientation?: number;
  51421. frontUVs?: Vector4;
  51422. backUVs?: Vector4;
  51423. updatable?: boolean;
  51424. }, scene?: Nullable<Scene>): Mesh;
  51425. /**
  51426. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51427. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  51428. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  51429. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  51430. * * 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
  51431. * * 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
  51432. * * 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
  51433. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51434. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51435. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51436. * * 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
  51437. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  51438. * * 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
  51439. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  51440. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51441. * @param name defines the name of the mesh
  51442. * @param options defines the options used to create the mesh
  51443. * @param scene defines the hosting scene
  51444. * @returns the ribbon mesh
  51445. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  51446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51447. */
  51448. static CreateRibbon(name: string, options: {
  51449. pathArray: Vector3[][];
  51450. closeArray?: boolean;
  51451. closePath?: boolean;
  51452. offset?: number;
  51453. updatable?: boolean;
  51454. sideOrientation?: number;
  51455. frontUVs?: Vector4;
  51456. backUVs?: Vector4;
  51457. instance?: Mesh;
  51458. invertUV?: boolean;
  51459. uvs?: Vector2[];
  51460. colors?: Color4[];
  51461. }, scene?: Nullable<Scene>): Mesh;
  51462. /**
  51463. * Creates a cylinder or a cone mesh
  51464. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  51465. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  51466. * * 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.
  51467. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  51468. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  51469. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  51470. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  51471. * * The parameter `cap` sets the way the cylinder is capped. Possible values : BABYLON.Mesh.NO_CAP, BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL (default).
  51472. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  51473. * * 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).
  51474. * * 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
  51475. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  51476. * * 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
  51477. * * 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.
  51478. * * If `enclose` is false, a ring surface is one element.
  51479. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  51480. * * 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
  51481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51483. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51484. * @param name defines the name of the mesh
  51485. * @param options defines the options used to create the mesh
  51486. * @param scene defines the hosting scene
  51487. * @returns the cylinder mesh
  51488. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  51489. */
  51490. static CreateCylinder(name: string, options: {
  51491. height?: number;
  51492. diameterTop?: number;
  51493. diameterBottom?: number;
  51494. diameter?: number;
  51495. tessellation?: number;
  51496. subdivisions?: number;
  51497. arc?: number;
  51498. faceColors?: Color4[];
  51499. faceUV?: Vector4[];
  51500. updatable?: boolean;
  51501. hasRings?: boolean;
  51502. enclose?: boolean;
  51503. cap?: number;
  51504. sideOrientation?: number;
  51505. frontUVs?: Vector4;
  51506. backUVs?: Vector4;
  51507. }, scene?: Nullable<Scene>): Mesh;
  51508. /**
  51509. * Creates a torus mesh
  51510. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  51511. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  51512. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  51513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51515. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51516. * @param name defines the name of the mesh
  51517. * @param options defines the options used to create the mesh
  51518. * @param scene defines the hosting scene
  51519. * @returns the torus mesh
  51520. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  51521. */
  51522. static CreateTorus(name: string, options: {
  51523. diameter?: number;
  51524. thickness?: number;
  51525. tessellation?: number;
  51526. updatable?: boolean;
  51527. sideOrientation?: number;
  51528. frontUVs?: Vector4;
  51529. backUVs?: Vector4;
  51530. }, scene?: Nullable<Scene>): Mesh;
  51531. /**
  51532. * Creates a torus knot mesh
  51533. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51534. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51535. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51536. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51539. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51540. * @param name defines the name of the mesh
  51541. * @param options defines the options used to create the mesh
  51542. * @param scene defines the hosting scene
  51543. * @returns the torus knot mesh
  51544. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51545. */
  51546. static CreateTorusKnot(name: string, options: {
  51547. radius?: number;
  51548. tube?: number;
  51549. radialSegments?: number;
  51550. tubularSegments?: number;
  51551. p?: number;
  51552. q?: number;
  51553. updatable?: boolean;
  51554. sideOrientation?: number;
  51555. frontUVs?: Vector4;
  51556. backUVs?: Vector4;
  51557. }, scene?: Nullable<Scene>): Mesh;
  51558. /**
  51559. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51560. * * 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
  51561. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51562. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51563. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51564. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51565. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51566. * * 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
  51567. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51569. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51570. * @param name defines the name of the new line system
  51571. * @param options defines the options used to create the line system
  51572. * @param scene defines the hosting scene
  51573. * @returns a new line system mesh
  51574. */
  51575. static CreateLineSystem(name: string, options: {
  51576. lines: Vector3[][];
  51577. updatable?: boolean;
  51578. instance?: Nullable<LinesMesh>;
  51579. colors?: Nullable<Color4[][]>;
  51580. useVertexAlpha?: boolean;
  51581. }, scene: Nullable<Scene>): LinesMesh;
  51582. /**
  51583. * Creates a line mesh
  51584. * 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
  51585. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51586. * * The parameter `points` is an array successive Vector3
  51587. * * 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
  51588. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51589. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51590. * * When updating an instance, remember that only point positions can change, not the number of points
  51591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51593. * @param name defines the name of the new line system
  51594. * @param options defines the options used to create the line system
  51595. * @param scene defines the hosting scene
  51596. * @returns a new line mesh
  51597. */
  51598. static CreateLines(name: string, options: {
  51599. points: Vector3[];
  51600. updatable?: boolean;
  51601. instance?: Nullable<LinesMesh>;
  51602. colors?: Color4[];
  51603. useVertexAlpha?: boolean;
  51604. }, scene?: Nullable<Scene>): LinesMesh;
  51605. /**
  51606. * Creates a dashed line mesh
  51607. * * 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
  51608. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51609. * * The parameter `points` is an array successive Vector3
  51610. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51611. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51612. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51613. * * 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
  51614. * * When updating an instance, remember that only point positions can change, not the number of points
  51615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51616. * @param name defines the name of the mesh
  51617. * @param options defines the options used to create the mesh
  51618. * @param scene defines the hosting scene
  51619. * @returns the dashed line mesh
  51620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51621. */
  51622. static CreateDashedLines(name: string, options: {
  51623. points: Vector3[];
  51624. dashSize?: number;
  51625. gapSize?: number;
  51626. dashNb?: number;
  51627. updatable?: boolean;
  51628. instance?: LinesMesh;
  51629. }, scene?: Nullable<Scene>): LinesMesh;
  51630. /**
  51631. * 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.
  51632. * * 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.
  51633. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51634. * * 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.
  51635. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  51636. * * 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
  51637. * * 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
  51638. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  51639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51641. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  51642. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51643. * @param name defines the name of the mesh
  51644. * @param options defines the options used to create the mesh
  51645. * @param scene defines the hosting scene
  51646. * @returns the extruded shape mesh
  51647. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51648. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51649. */
  51650. static ExtrudeShape(name: string, options: {
  51651. shape: Vector3[];
  51652. path: Vector3[];
  51653. scale?: number;
  51654. rotation?: number;
  51655. cap?: number;
  51656. updatable?: boolean;
  51657. sideOrientation?: number;
  51658. frontUVs?: Vector4;
  51659. backUVs?: Vector4;
  51660. instance?: Mesh;
  51661. invertUV?: boolean;
  51662. }, scene?: Nullable<Scene>): Mesh;
  51663. /**
  51664. * Creates an custom extruded shape mesh.
  51665. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  51666. * * 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.
  51667. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  51668. * * 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
  51669. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  51670. * * 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
  51671. * * It must returns a float value that will be the scale value applied to the shape on each path point
  51672. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  51673. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  51674. * * 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
  51675. * * 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
  51676. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  51677. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51678. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51679. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51680. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51681. * @param name defines the name of the mesh
  51682. * @param options defines the options used to create the mesh
  51683. * @param scene defines the hosting scene
  51684. * @returns the custom extruded shape mesh
  51685. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51686. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51688. */
  51689. static ExtrudeShapeCustom(name: string, options: {
  51690. shape: Vector3[];
  51691. path: Vector3[];
  51692. scaleFunction?: any;
  51693. rotationFunction?: any;
  51694. ribbonCloseArray?: boolean;
  51695. ribbonClosePath?: boolean;
  51696. cap?: number;
  51697. updatable?: boolean;
  51698. sideOrientation?: number;
  51699. frontUVs?: Vector4;
  51700. backUVs?: Vector4;
  51701. instance?: Mesh;
  51702. invertUV?: boolean;
  51703. }, scene?: Nullable<Scene>): Mesh;
  51704. /**
  51705. * Creates lathe mesh.
  51706. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  51707. * * 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
  51708. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  51709. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  51710. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  51711. * * 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
  51712. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  51713. * * 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
  51714. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51715. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51716. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51717. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51718. * @param name defines the name of the mesh
  51719. * @param options defines the options used to create the mesh
  51720. * @param scene defines the hosting scene
  51721. * @returns the lathe mesh
  51722. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  51723. */
  51724. static CreateLathe(name: string, options: {
  51725. shape: Vector3[];
  51726. radius?: number;
  51727. tessellation?: number;
  51728. clip?: number;
  51729. arc?: number;
  51730. closed?: boolean;
  51731. updatable?: boolean;
  51732. sideOrientation?: number;
  51733. frontUVs?: Vector4;
  51734. backUVs?: Vector4;
  51735. cap?: number;
  51736. invertUV?: boolean;
  51737. }, scene?: Nullable<Scene>): Mesh;
  51738. /**
  51739. * Creates a tiled plane mesh
  51740. * * You can set a limited pattern arrangement with the tiles
  51741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51744. * @param name defines the name of the mesh
  51745. * @param options defines the options used to create the mesh
  51746. * @param scene defines the hosting scene
  51747. * @returns the plane mesh
  51748. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51749. */
  51750. static CreateTiledPlane(name: string, options: {
  51751. pattern?: number;
  51752. tileSize?: number;
  51753. tileWidth?: number;
  51754. tileHeight?: number;
  51755. size?: number;
  51756. width?: number;
  51757. height?: number;
  51758. alignHorizontal?: number;
  51759. alignVertical?: number;
  51760. sideOrientation?: number;
  51761. frontUVs?: Vector4;
  51762. backUVs?: Vector4;
  51763. updatable?: boolean;
  51764. }, scene?: Nullable<Scene>): Mesh;
  51765. /**
  51766. * Creates a plane mesh
  51767. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  51768. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  51769. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  51770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51773. * @param name defines the name of the mesh
  51774. * @param options defines the options used to create the mesh
  51775. * @param scene defines the hosting scene
  51776. * @returns the plane mesh
  51777. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  51778. */
  51779. static CreatePlane(name: string, options: {
  51780. size?: number;
  51781. width?: number;
  51782. height?: number;
  51783. sideOrientation?: number;
  51784. frontUVs?: Vector4;
  51785. backUVs?: Vector4;
  51786. updatable?: boolean;
  51787. sourcePlane?: Plane;
  51788. }, scene?: Nullable<Scene>): Mesh;
  51789. /**
  51790. * Creates a ground mesh
  51791. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51792. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51794. * @param name defines the name of the mesh
  51795. * @param options defines the options used to create the mesh
  51796. * @param scene defines the hosting scene
  51797. * @returns the ground mesh
  51798. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51799. */
  51800. static CreateGround(name: string, options: {
  51801. width?: number;
  51802. height?: number;
  51803. subdivisions?: number;
  51804. subdivisionsX?: number;
  51805. subdivisionsY?: number;
  51806. updatable?: boolean;
  51807. }, scene?: Nullable<Scene>): Mesh;
  51808. /**
  51809. * Creates a tiled ground mesh
  51810. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51811. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51812. * * 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
  51813. * * 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
  51814. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51815. * @param name defines the name of the mesh
  51816. * @param options defines the options used to create the mesh
  51817. * @param scene defines the hosting scene
  51818. * @returns the tiled ground mesh
  51819. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51820. */
  51821. static CreateTiledGround(name: string, options: {
  51822. xmin: number;
  51823. zmin: number;
  51824. xmax: number;
  51825. zmax: number;
  51826. subdivisions?: {
  51827. w: number;
  51828. h: number;
  51829. };
  51830. precision?: {
  51831. w: number;
  51832. h: number;
  51833. };
  51834. updatable?: boolean;
  51835. }, scene?: Nullable<Scene>): Mesh;
  51836. /**
  51837. * Creates a ground mesh from a height map
  51838. * * The parameter `url` sets the URL of the height map image resource.
  51839. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51840. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51841. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51842. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51843. * * 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.
  51844. * * 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).
  51845. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  51846. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51847. * @param name defines the name of the mesh
  51848. * @param url defines the url to the height map
  51849. * @param options defines the options used to create the mesh
  51850. * @param scene defines the hosting scene
  51851. * @returns the ground mesh
  51852. * @see https://doc.babylonjs.com/babylon101/height_map
  51853. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  51854. */
  51855. static CreateGroundFromHeightMap(name: string, url: string, options: {
  51856. width?: number;
  51857. height?: number;
  51858. subdivisions?: number;
  51859. minHeight?: number;
  51860. maxHeight?: number;
  51861. colorFilter?: Color3;
  51862. alphaFilter?: number;
  51863. updatable?: boolean;
  51864. onReady?: (mesh: GroundMesh) => void;
  51865. }, scene?: Nullable<Scene>): GroundMesh;
  51866. /**
  51867. * Creates a polygon mesh
  51868. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  51869. * * 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
  51870. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  51871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  51873. * * Remember you can only change the shape positions, not their number when updating a polygon
  51874. * @param name defines the name of the mesh
  51875. * @param options defines the options used to create the mesh
  51876. * @param scene defines the hosting scene
  51877. * @param earcutInjection can be used to inject your own earcut reference
  51878. * @returns the polygon mesh
  51879. */
  51880. static CreatePolygon(name: string, options: {
  51881. shape: Vector3[];
  51882. holes?: Vector3[][];
  51883. depth?: number;
  51884. faceUV?: Vector4[];
  51885. faceColors?: Color4[];
  51886. updatable?: boolean;
  51887. sideOrientation?: number;
  51888. frontUVs?: Vector4;
  51889. backUVs?: Vector4;
  51890. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51891. /**
  51892. * Creates an extruded polygon mesh, with depth in the Y direction.
  51893. * * 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)
  51894. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51895. * @param name defines the name of the mesh
  51896. * @param options defines the options used to create the mesh
  51897. * @param scene defines the hosting scene
  51898. * @param earcutInjection can be used to inject your own earcut reference
  51899. * @returns the polygon mesh
  51900. */
  51901. static ExtrudePolygon(name: string, options: {
  51902. shape: Vector3[];
  51903. holes?: Vector3[][];
  51904. depth?: number;
  51905. faceUV?: Vector4[];
  51906. faceColors?: Color4[];
  51907. updatable?: boolean;
  51908. sideOrientation?: number;
  51909. frontUVs?: Vector4;
  51910. backUVs?: Vector4;
  51911. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  51912. /**
  51913. * Creates a tube mesh.
  51914. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  51915. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  51916. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  51917. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  51918. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  51919. * * 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)
  51920. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  51921. * * 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
  51922. * * 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
  51923. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51924. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51925. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  51926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51927. * @param name defines the name of the mesh
  51928. * @param options defines the options used to create the mesh
  51929. * @param scene defines the hosting scene
  51930. * @returns the tube mesh
  51931. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51932. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  51933. */
  51934. static CreateTube(name: string, options: {
  51935. path: Vector3[];
  51936. radius?: number;
  51937. tessellation?: number;
  51938. radiusFunction?: {
  51939. (i: number, distance: number): number;
  51940. };
  51941. cap?: number;
  51942. arc?: number;
  51943. updatable?: boolean;
  51944. sideOrientation?: number;
  51945. frontUVs?: Vector4;
  51946. backUVs?: Vector4;
  51947. instance?: Mesh;
  51948. invertUV?: boolean;
  51949. }, scene?: Nullable<Scene>): Mesh;
  51950. /**
  51951. * Creates a polyhedron mesh
  51952. * * 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
  51953. * * The parameter `size` (positive float, default 1) sets the polygon size
  51954. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  51955. * * 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`
  51956. * * 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
  51957. * * 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)`)
  51958. * * 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
  51959. * * 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
  51960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51961. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51963. * @param name defines the name of the mesh
  51964. * @param options defines the options used to create the mesh
  51965. * @param scene defines the hosting scene
  51966. * @returns the polyhedron mesh
  51967. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  51968. */
  51969. static CreatePolyhedron(name: string, options: {
  51970. type?: number;
  51971. size?: number;
  51972. sizeX?: number;
  51973. sizeY?: number;
  51974. sizeZ?: number;
  51975. custom?: any;
  51976. faceUV?: Vector4[];
  51977. faceColors?: Color4[];
  51978. flat?: boolean;
  51979. updatable?: boolean;
  51980. sideOrientation?: number;
  51981. frontUVs?: Vector4;
  51982. backUVs?: Vector4;
  51983. }, scene?: Nullable<Scene>): Mesh;
  51984. /**
  51985. * Creates a decal mesh.
  51986. * 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
  51987. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  51988. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  51989. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  51990. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  51991. * @param name defines the name of the mesh
  51992. * @param sourceMesh defines the mesh where the decal must be applied
  51993. * @param options defines the options used to create the mesh
  51994. * @param scene defines the hosting scene
  51995. * @returns the decal mesh
  51996. * @see https://doc.babylonjs.com/how_to/decals
  51997. */
  51998. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  51999. position?: Vector3;
  52000. normal?: Vector3;
  52001. size?: Vector3;
  52002. angle?: number;
  52003. }): Mesh;
  52004. }
  52005. }
  52006. declare module BABYLON {
  52007. /**
  52008. * A simplifier interface for future simplification implementations
  52009. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52010. */
  52011. export interface ISimplifier {
  52012. /**
  52013. * Simplification of a given mesh according to the given settings.
  52014. * Since this requires computation, it is assumed that the function runs async.
  52015. * @param settings The settings of the simplification, including quality and distance
  52016. * @param successCallback A callback that will be called after the mesh was simplified.
  52017. * @param errorCallback in case of an error, this callback will be called. optional.
  52018. */
  52019. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52020. }
  52021. /**
  52022. * Expected simplification settings.
  52023. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52024. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52025. */
  52026. export interface ISimplificationSettings {
  52027. /**
  52028. * Gets or sets the expected quality
  52029. */
  52030. quality: number;
  52031. /**
  52032. * Gets or sets the distance when this optimized version should be used
  52033. */
  52034. distance: number;
  52035. /**
  52036. * Gets an already optimized mesh
  52037. */
  52038. optimizeMesh?: boolean;
  52039. }
  52040. /**
  52041. * Class used to specify simplification options
  52042. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52043. */
  52044. export class SimplificationSettings implements ISimplificationSettings {
  52045. /** expected quality */
  52046. quality: number;
  52047. /** distance when this optimized version should be used */
  52048. distance: number;
  52049. /** already optimized mesh */
  52050. optimizeMesh?: boolean | undefined;
  52051. /**
  52052. * Creates a SimplificationSettings
  52053. * @param quality expected quality
  52054. * @param distance distance when this optimized version should be used
  52055. * @param optimizeMesh already optimized mesh
  52056. */
  52057. constructor(
  52058. /** expected quality */
  52059. quality: number,
  52060. /** distance when this optimized version should be used */
  52061. distance: number,
  52062. /** already optimized mesh */
  52063. optimizeMesh?: boolean | undefined);
  52064. }
  52065. /**
  52066. * Interface used to define a simplification task
  52067. */
  52068. export interface ISimplificationTask {
  52069. /**
  52070. * Array of settings
  52071. */
  52072. settings: Array<ISimplificationSettings>;
  52073. /**
  52074. * Simplification type
  52075. */
  52076. simplificationType: SimplificationType;
  52077. /**
  52078. * Mesh to simplify
  52079. */
  52080. mesh: Mesh;
  52081. /**
  52082. * Callback called on success
  52083. */
  52084. successCallback?: () => void;
  52085. /**
  52086. * Defines if parallel processing can be used
  52087. */
  52088. parallelProcessing: boolean;
  52089. }
  52090. /**
  52091. * Queue used to order the simplification tasks
  52092. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52093. */
  52094. export class SimplificationQueue {
  52095. private _simplificationArray;
  52096. /**
  52097. * Gets a boolean indicating that the process is still running
  52098. */
  52099. running: boolean;
  52100. /**
  52101. * Creates a new queue
  52102. */
  52103. constructor();
  52104. /**
  52105. * Adds a new simplification task
  52106. * @param task defines a task to add
  52107. */
  52108. addTask(task: ISimplificationTask): void;
  52109. /**
  52110. * Execute next task
  52111. */
  52112. executeNext(): void;
  52113. /**
  52114. * Execute a simplification task
  52115. * @param task defines the task to run
  52116. */
  52117. runSimplification(task: ISimplificationTask): void;
  52118. private getSimplifier;
  52119. }
  52120. /**
  52121. * The implemented types of simplification
  52122. * At the moment only Quadratic Error Decimation is implemented
  52123. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52124. */
  52125. export enum SimplificationType {
  52126. /** Quadratic error decimation */
  52127. QUADRATIC = 0
  52128. }
  52129. }
  52130. declare module BABYLON {
  52131. interface Scene {
  52132. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  52133. /**
  52134. * Gets or sets the simplification queue attached to the scene
  52135. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52136. */
  52137. simplificationQueue: SimplificationQueue;
  52138. }
  52139. interface Mesh {
  52140. /**
  52141. * Simplify the mesh according to the given array of settings.
  52142. * Function will return immediately and will simplify async
  52143. * @param settings a collection of simplification settings
  52144. * @param parallelProcessing should all levels calculate parallel or one after the other
  52145. * @param simplificationType the type of simplification to run
  52146. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  52147. * @returns the current mesh
  52148. */
  52149. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  52150. }
  52151. /**
  52152. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  52153. * created in a scene
  52154. */
  52155. export class SimplicationQueueSceneComponent implements ISceneComponent {
  52156. /**
  52157. * The component name helpfull to identify the component in the list of scene components.
  52158. */
  52159. readonly name: string;
  52160. /**
  52161. * The scene the component belongs to.
  52162. */
  52163. scene: Scene;
  52164. /**
  52165. * Creates a new instance of the component for the given scene
  52166. * @param scene Defines the scene to register the component in
  52167. */
  52168. constructor(scene: Scene);
  52169. /**
  52170. * Registers the component in a given scene
  52171. */
  52172. register(): void;
  52173. /**
  52174. * Rebuilds the elements related to this component in case of
  52175. * context lost for instance.
  52176. */
  52177. rebuild(): void;
  52178. /**
  52179. * Disposes the component and the associated ressources
  52180. */
  52181. dispose(): void;
  52182. private _beforeCameraUpdate;
  52183. }
  52184. }
  52185. declare module BABYLON {
  52186. /**
  52187. * Class used to enable access to IndexedDB
  52188. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  52189. */
  52190. export class Database implements IOfflineProvider {
  52191. private _callbackManifestChecked;
  52192. private _currentSceneUrl;
  52193. private _db;
  52194. private _enableSceneOffline;
  52195. private _enableTexturesOffline;
  52196. private _manifestVersionFound;
  52197. private _mustUpdateRessources;
  52198. private _hasReachedQuota;
  52199. private _isSupported;
  52200. private _idbFactory;
  52201. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  52202. private static IsUASupportingBlobStorage;
  52203. /**
  52204. * Gets a boolean indicating if Database storate is enabled (off by default)
  52205. */
  52206. static IDBStorageEnabled: boolean;
  52207. /**
  52208. * Gets a boolean indicating if scene must be saved in the database
  52209. */
  52210. readonly enableSceneOffline: boolean;
  52211. /**
  52212. * Gets a boolean indicating if textures must be saved in the database
  52213. */
  52214. readonly enableTexturesOffline: boolean;
  52215. /**
  52216. * Creates a new Database
  52217. * @param urlToScene defines the url to load the scene
  52218. * @param callbackManifestChecked defines the callback to use when manifest is checked
  52219. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  52220. */
  52221. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  52222. private static _ParseURL;
  52223. private static _ReturnFullUrlLocation;
  52224. private _checkManifestFile;
  52225. /**
  52226. * Open the database and make it available
  52227. * @param successCallback defines the callback to call on success
  52228. * @param errorCallback defines the callback to call on error
  52229. */
  52230. open(successCallback: () => void, errorCallback: () => void): void;
  52231. /**
  52232. * Loads an image from the database
  52233. * @param url defines the url to load from
  52234. * @param image defines the target DOM image
  52235. */
  52236. loadImage(url: string, image: HTMLImageElement): void;
  52237. private _loadImageFromDBAsync;
  52238. private _saveImageIntoDBAsync;
  52239. private _checkVersionFromDB;
  52240. private _loadVersionFromDBAsync;
  52241. private _saveVersionIntoDBAsync;
  52242. /**
  52243. * Loads a file from database
  52244. * @param url defines the URL to load from
  52245. * @param sceneLoaded defines a callback to call on success
  52246. * @param progressCallBack defines a callback to call when progress changed
  52247. * @param errorCallback defines a callback to call on error
  52248. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  52249. */
  52250. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  52251. private _loadFileAsync;
  52252. private _saveFileAsync;
  52253. /**
  52254. * Validates if xhr data is correct
  52255. * @param xhr defines the request to validate
  52256. * @param dataType defines the expected data type
  52257. * @returns true if data is correct
  52258. */
  52259. private static _ValidateXHRData;
  52260. }
  52261. }
  52262. declare module BABYLON {
  52263. /** @hidden */
  52264. export var gpuUpdateParticlesPixelShader: {
  52265. name: string;
  52266. shader: string;
  52267. };
  52268. }
  52269. declare module BABYLON {
  52270. /** @hidden */
  52271. export var gpuUpdateParticlesVertexShader: {
  52272. name: string;
  52273. shader: string;
  52274. };
  52275. }
  52276. declare module BABYLON {
  52277. /** @hidden */
  52278. export var clipPlaneFragmentDeclaration2: {
  52279. name: string;
  52280. shader: string;
  52281. };
  52282. }
  52283. declare module BABYLON {
  52284. /** @hidden */
  52285. export var gpuRenderParticlesPixelShader: {
  52286. name: string;
  52287. shader: string;
  52288. };
  52289. }
  52290. declare module BABYLON {
  52291. /** @hidden */
  52292. export var clipPlaneVertexDeclaration2: {
  52293. name: string;
  52294. shader: string;
  52295. };
  52296. }
  52297. declare module BABYLON {
  52298. /** @hidden */
  52299. export var gpuRenderParticlesVertexShader: {
  52300. name: string;
  52301. shader: string;
  52302. };
  52303. }
  52304. declare module BABYLON {
  52305. /**
  52306. * This represents a GPU particle system in Babylon
  52307. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  52308. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  52309. */
  52310. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  52311. /**
  52312. * The layer mask we are rendering the particles through.
  52313. */
  52314. layerMask: number;
  52315. private _capacity;
  52316. private _activeCount;
  52317. private _currentActiveCount;
  52318. private _accumulatedCount;
  52319. private _renderEffect;
  52320. private _updateEffect;
  52321. private _buffer0;
  52322. private _buffer1;
  52323. private _spriteBuffer;
  52324. private _updateVAO;
  52325. private _renderVAO;
  52326. private _targetIndex;
  52327. private _sourceBuffer;
  52328. private _targetBuffer;
  52329. private _engine;
  52330. private _currentRenderId;
  52331. private _started;
  52332. private _stopped;
  52333. private _timeDelta;
  52334. private _randomTexture;
  52335. private _randomTexture2;
  52336. private _attributesStrideSize;
  52337. private _updateEffectOptions;
  52338. private _randomTextureSize;
  52339. private _actualFrame;
  52340. private readonly _rawTextureWidth;
  52341. /**
  52342. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  52343. */
  52344. static readonly IsSupported: boolean;
  52345. /**
  52346. * An event triggered when the system is disposed.
  52347. */
  52348. onDisposeObservable: Observable<GPUParticleSystem>;
  52349. /**
  52350. * Gets the maximum number of particles active at the same time.
  52351. * @returns The max number of active particles.
  52352. */
  52353. getCapacity(): number;
  52354. /**
  52355. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  52356. * to override the particles.
  52357. */
  52358. forceDepthWrite: boolean;
  52359. /**
  52360. * Gets or set the number of active particles
  52361. */
  52362. activeParticleCount: number;
  52363. private _preWarmDone;
  52364. /**
  52365. * Is this system ready to be used/rendered
  52366. * @return true if the system is ready
  52367. */
  52368. isReady(): boolean;
  52369. /**
  52370. * Gets if the system has been started. (Note: this will still be true after stop is called)
  52371. * @returns True if it has been started, otherwise false.
  52372. */
  52373. isStarted(): boolean;
  52374. /**
  52375. * Starts the particle system and begins to emit
  52376. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  52377. */
  52378. start(delay?: number): void;
  52379. /**
  52380. * Stops the particle system.
  52381. */
  52382. stop(): void;
  52383. /**
  52384. * Remove all active particles
  52385. */
  52386. reset(): void;
  52387. /**
  52388. * Returns the string "GPUParticleSystem"
  52389. * @returns a string containing the class name
  52390. */
  52391. getClassName(): string;
  52392. private _colorGradientsTexture;
  52393. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  52394. /**
  52395. * Adds a new color gradient
  52396. * @param gradient defines the gradient to use (between 0 and 1)
  52397. * @param color1 defines the color to affect to the specified gradient
  52398. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  52399. * @returns the current particle system
  52400. */
  52401. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  52402. /**
  52403. * Remove a specific color gradient
  52404. * @param gradient defines the gradient to remove
  52405. * @returns the current particle system
  52406. */
  52407. removeColorGradient(gradient: number): GPUParticleSystem;
  52408. private _angularSpeedGradientsTexture;
  52409. private _sizeGradientsTexture;
  52410. private _velocityGradientsTexture;
  52411. private _limitVelocityGradientsTexture;
  52412. private _dragGradientsTexture;
  52413. private _addFactorGradient;
  52414. /**
  52415. * Adds a new size gradient
  52416. * @param gradient defines the gradient to use (between 0 and 1)
  52417. * @param factor defines the size factor to affect to the specified gradient
  52418. * @returns the current particle system
  52419. */
  52420. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  52421. /**
  52422. * Remove a specific size gradient
  52423. * @param gradient defines the gradient to remove
  52424. * @returns the current particle system
  52425. */
  52426. removeSizeGradient(gradient: number): GPUParticleSystem;
  52427. /**
  52428. * Adds a new angular speed gradient
  52429. * @param gradient defines the gradient to use (between 0 and 1)
  52430. * @param factor defines the angular speed to affect to the specified gradient
  52431. * @returns the current particle system
  52432. */
  52433. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  52434. /**
  52435. * Remove a specific angular speed gradient
  52436. * @param gradient defines the gradient to remove
  52437. * @returns the current particle system
  52438. */
  52439. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  52440. /**
  52441. * Adds a new velocity gradient
  52442. * @param gradient defines the gradient to use (between 0 and 1)
  52443. * @param factor defines the velocity to affect to the specified gradient
  52444. * @returns the current particle system
  52445. */
  52446. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52447. /**
  52448. * Remove a specific velocity gradient
  52449. * @param gradient defines the gradient to remove
  52450. * @returns the current particle system
  52451. */
  52452. removeVelocityGradient(gradient: number): GPUParticleSystem;
  52453. /**
  52454. * Adds a new limit velocity gradient
  52455. * @param gradient defines the gradient to use (between 0 and 1)
  52456. * @param factor defines the limit velocity value to affect to the specified gradient
  52457. * @returns the current particle system
  52458. */
  52459. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  52460. /**
  52461. * Remove a specific limit velocity gradient
  52462. * @param gradient defines the gradient to remove
  52463. * @returns the current particle system
  52464. */
  52465. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  52466. /**
  52467. * Adds a new drag gradient
  52468. * @param gradient defines the gradient to use (between 0 and 1)
  52469. * @param factor defines the drag value to affect to the specified gradient
  52470. * @returns the current particle system
  52471. */
  52472. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  52473. /**
  52474. * Remove a specific drag gradient
  52475. * @param gradient defines the gradient to remove
  52476. * @returns the current particle system
  52477. */
  52478. removeDragGradient(gradient: number): GPUParticleSystem;
  52479. /**
  52480. * Not supported by GPUParticleSystem
  52481. * @param gradient defines the gradient to use (between 0 and 1)
  52482. * @param factor defines the emit rate value to affect to the specified gradient
  52483. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52484. * @returns the current particle system
  52485. */
  52486. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52487. /**
  52488. * Not supported by GPUParticleSystem
  52489. * @param gradient defines the gradient to remove
  52490. * @returns the current particle system
  52491. */
  52492. removeEmitRateGradient(gradient: number): IParticleSystem;
  52493. /**
  52494. * Not supported by GPUParticleSystem
  52495. * @param gradient defines the gradient to use (between 0 and 1)
  52496. * @param factor defines the start size value to affect to the specified gradient
  52497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52498. * @returns the current particle system
  52499. */
  52500. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52501. /**
  52502. * Not supported by GPUParticleSystem
  52503. * @param gradient defines the gradient to remove
  52504. * @returns the current particle system
  52505. */
  52506. removeStartSizeGradient(gradient: number): IParticleSystem;
  52507. /**
  52508. * Not supported by GPUParticleSystem
  52509. * @param gradient defines the gradient to use (between 0 and 1)
  52510. * @param min defines the color remap minimal range
  52511. * @param max defines the color remap maximal range
  52512. * @returns the current particle system
  52513. */
  52514. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52515. /**
  52516. * Not supported by GPUParticleSystem
  52517. * @param gradient defines the gradient to remove
  52518. * @returns the current particle system
  52519. */
  52520. removeColorRemapGradient(): IParticleSystem;
  52521. /**
  52522. * Not supported by GPUParticleSystem
  52523. * @param gradient defines the gradient to use (between 0 and 1)
  52524. * @param min defines the alpha remap minimal range
  52525. * @param max defines the alpha remap maximal range
  52526. * @returns the current particle system
  52527. */
  52528. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  52529. /**
  52530. * Not supported by GPUParticleSystem
  52531. * @param gradient defines the gradient to remove
  52532. * @returns the current particle system
  52533. */
  52534. removeAlphaRemapGradient(): IParticleSystem;
  52535. /**
  52536. * Not supported by GPUParticleSystem
  52537. * @param gradient defines the gradient to use (between 0 and 1)
  52538. * @param color defines the color to affect to the specified gradient
  52539. * @returns the current particle system
  52540. */
  52541. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  52542. /**
  52543. * Not supported by GPUParticleSystem
  52544. * @param gradient defines the gradient to remove
  52545. * @returns the current particle system
  52546. */
  52547. removeRampGradient(): IParticleSystem;
  52548. /**
  52549. * Not supported by GPUParticleSystem
  52550. * @returns the list of ramp gradients
  52551. */
  52552. getRampGradients(): Nullable<Array<Color3Gradient>>;
  52553. /**
  52554. * Not supported by GPUParticleSystem
  52555. * Gets or sets a boolean indicating that ramp gradients must be used
  52556. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  52557. */
  52558. useRampGradients: boolean;
  52559. /**
  52560. * Not supported by GPUParticleSystem
  52561. * @param gradient defines the gradient to use (between 0 and 1)
  52562. * @param factor defines the life time factor to affect to the specified gradient
  52563. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  52564. * @returns the current particle system
  52565. */
  52566. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  52567. /**
  52568. * Not supported by GPUParticleSystem
  52569. * @param gradient defines the gradient to remove
  52570. * @returns the current particle system
  52571. */
  52572. removeLifeTimeGradient(gradient: number): IParticleSystem;
  52573. /**
  52574. * Instantiates a GPU particle system.
  52575. * 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.
  52576. * @param name The name of the particle system
  52577. * @param options The options used to create the system
  52578. * @param scene The scene the particle system belongs to
  52579. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  52580. */
  52581. constructor(name: string, options: Partial<{
  52582. capacity: number;
  52583. randomTextureSize: number;
  52584. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  52585. protected _reset(): void;
  52586. private _createUpdateVAO;
  52587. private _createRenderVAO;
  52588. private _initialize;
  52589. /** @hidden */ private _recreateUpdateEffect(): void;
  52590. /** @hidden */ private _recreateRenderEffect(): void;
  52591. /**
  52592. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  52593. * @param preWarm defines if we are in the pre-warmimg phase
  52594. */
  52595. animate(preWarm?: boolean): void;
  52596. private _createFactorGradientTexture;
  52597. private _createSizeGradientTexture;
  52598. private _createAngularSpeedGradientTexture;
  52599. private _createVelocityGradientTexture;
  52600. private _createLimitVelocityGradientTexture;
  52601. private _createDragGradientTexture;
  52602. private _createColorGradientTexture;
  52603. /**
  52604. * Renders the particle system in its current state
  52605. * @param preWarm defines if the system should only update the particles but not render them
  52606. * @returns the current number of particles
  52607. */
  52608. render(preWarm?: boolean): number;
  52609. /**
  52610. * Rebuilds the particle system
  52611. */
  52612. rebuild(): void;
  52613. private _releaseBuffers;
  52614. private _releaseVAOs;
  52615. /**
  52616. * Disposes the particle system and free the associated resources
  52617. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  52618. */
  52619. dispose(disposeTexture?: boolean): void;
  52620. /**
  52621. * Clones the particle system.
  52622. * @param name The name of the cloned object
  52623. * @param newEmitter The new emitter to use
  52624. * @returns the cloned particle system
  52625. */
  52626. clone(name: string, newEmitter: any): GPUParticleSystem;
  52627. /**
  52628. * Serializes the particle system to a JSON object.
  52629. * @returns the JSON object
  52630. */
  52631. serialize(): any;
  52632. /**
  52633. * Parses a JSON object to create a GPU particle system.
  52634. * @param parsedParticleSystem The JSON object to parse
  52635. * @param scene The scene to create the particle system in
  52636. * @param rootUrl The root url to use to load external dependencies like texture
  52637. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  52638. * @returns the parsed GPU particle system
  52639. */
  52640. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  52641. }
  52642. }
  52643. declare module BABYLON {
  52644. /**
  52645. * Represents a set of particle systems working together to create a specific effect
  52646. */
  52647. export class ParticleSystemSet implements IDisposable {
  52648. private _emitterCreationOptions;
  52649. private _emitterNode;
  52650. /**
  52651. * Gets the particle system list
  52652. */
  52653. systems: IParticleSystem[];
  52654. /**
  52655. * Gets the emitter node used with this set
  52656. */
  52657. readonly emitterNode: Nullable<TransformNode>;
  52658. /**
  52659. * Creates a new emitter mesh as a sphere
  52660. * @param options defines the options used to create the sphere
  52661. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  52662. * @param scene defines the hosting scene
  52663. */
  52664. setEmitterAsSphere(options: {
  52665. diameter: number;
  52666. segments: number;
  52667. color: Color3;
  52668. }, renderingGroupId: number, scene: Scene): void;
  52669. /**
  52670. * Starts all particle systems of the set
  52671. * @param emitter defines an optional mesh to use as emitter for the particle systems
  52672. */
  52673. start(emitter?: AbstractMesh): void;
  52674. /**
  52675. * Release all associated resources
  52676. */
  52677. dispose(): void;
  52678. /**
  52679. * Serialize the set into a JSON compatible object
  52680. * @returns a JSON compatible representation of the set
  52681. */
  52682. serialize(): any;
  52683. /**
  52684. * Parse a new ParticleSystemSet from a serialized source
  52685. * @param data defines a JSON compatible representation of the set
  52686. * @param scene defines the hosting scene
  52687. * @param gpu defines if we want GPU particles or CPU particles
  52688. * @returns a new ParticleSystemSet
  52689. */
  52690. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  52691. }
  52692. }
  52693. declare module BABYLON {
  52694. /**
  52695. * This class is made for on one-liner static method to help creating particle system set.
  52696. */
  52697. export class ParticleHelper {
  52698. /**
  52699. * Gets or sets base Assets URL
  52700. */
  52701. static BaseAssetsUrl: string;
  52702. /**
  52703. * Create a default particle system that you can tweak
  52704. * @param emitter defines the emitter to use
  52705. * @param capacity defines the system capacity (default is 500 particles)
  52706. * @param scene defines the hosting scene
  52707. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  52708. * @returns the new Particle system
  52709. */
  52710. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  52711. /**
  52712. * This is the main static method (one-liner) of this helper to create different particle systems
  52713. * @param type This string represents the type to the particle system to create
  52714. * @param scene The scene where the particle system should live
  52715. * @param gpu If the system will use gpu
  52716. * @returns the ParticleSystemSet created
  52717. */
  52718. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  52719. /**
  52720. * Static function used to export a particle system to a ParticleSystemSet variable.
  52721. * Please note that the emitter shape is not exported
  52722. * @param systems defines the particle systems to export
  52723. * @returns the created particle system set
  52724. */
  52725. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  52726. }
  52727. }
  52728. declare module BABYLON {
  52729. interface Engine {
  52730. /**
  52731. * Create an effect to use with particle systems.
  52732. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  52733. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  52734. * @param uniformsNames defines a list of attribute names
  52735. * @param samplers defines an array of string used to represent textures
  52736. * @param defines defines the string containing the defines to use to compile the shaders
  52737. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  52738. * @param onCompiled defines a function to call when the effect creation is successful
  52739. * @param onError defines a function to call when the effect creation has failed
  52740. * @returns the new Effect
  52741. */
  52742. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  52743. }
  52744. interface Mesh {
  52745. /**
  52746. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  52747. * @returns an array of IParticleSystem
  52748. */
  52749. getEmittedParticleSystems(): IParticleSystem[];
  52750. /**
  52751. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  52752. * @returns an array of IParticleSystem
  52753. */
  52754. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  52755. }
  52756. /**
  52757. * @hidden
  52758. */
  52759. export var _IDoNeedToBeInTheBuild: number;
  52760. }
  52761. declare module BABYLON {
  52762. interface Scene {
  52763. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  52764. /**
  52765. * Gets the current physics engine
  52766. * @returns a IPhysicsEngine or null if none attached
  52767. */
  52768. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  52769. /**
  52770. * Enables physics to the current scene
  52771. * @param gravity defines the scene's gravity for the physics engine
  52772. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  52773. * @return a boolean indicating if the physics engine was initialized
  52774. */
  52775. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  52776. /**
  52777. * Disables and disposes the physics engine associated with the scene
  52778. */
  52779. disablePhysicsEngine(): void;
  52780. /**
  52781. * Gets a boolean indicating if there is an active physics engine
  52782. * @returns a boolean indicating if there is an active physics engine
  52783. */
  52784. isPhysicsEnabled(): boolean;
  52785. /**
  52786. * Deletes a physics compound impostor
  52787. * @param compound defines the compound to delete
  52788. */
  52789. deleteCompoundImpostor(compound: any): void;
  52790. /**
  52791. * An event triggered when physic simulation is about to be run
  52792. */
  52793. onBeforePhysicsObservable: Observable<Scene>;
  52794. /**
  52795. * An event triggered when physic simulation has been done
  52796. */
  52797. onAfterPhysicsObservable: Observable<Scene>;
  52798. }
  52799. interface AbstractMesh {
  52800. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  52801. /**
  52802. * Gets or sets impostor used for physic simulation
  52803. * @see http://doc.babylonjs.com/features/physics_engine
  52804. */
  52805. physicsImpostor: Nullable<PhysicsImpostor>;
  52806. /**
  52807. * Gets the current physics impostor
  52808. * @see http://doc.babylonjs.com/features/physics_engine
  52809. * @returns a physics impostor or null
  52810. */
  52811. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  52812. /** Apply a physic impulse to the mesh
  52813. * @param force defines the force to apply
  52814. * @param contactPoint defines where to apply the force
  52815. * @returns the current mesh
  52816. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  52817. */
  52818. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  52819. /**
  52820. * Creates a physic joint between two meshes
  52821. * @param otherMesh defines the other mesh to use
  52822. * @param pivot1 defines the pivot to use on this mesh
  52823. * @param pivot2 defines the pivot to use on the other mesh
  52824. * @param options defines additional options (can be plugin dependent)
  52825. * @returns the current mesh
  52826. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  52827. */
  52828. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  52829. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  52830. }
  52831. /**
  52832. * Defines the physics engine scene component responsible to manage a physics engine
  52833. */
  52834. export class PhysicsEngineSceneComponent implements ISceneComponent {
  52835. /**
  52836. * The component name helpful to identify the component in the list of scene components.
  52837. */
  52838. readonly name: string;
  52839. /**
  52840. * The scene the component belongs to.
  52841. */
  52842. scene: Scene;
  52843. /**
  52844. * Creates a new instance of the component for the given scene
  52845. * @param scene Defines the scene to register the component in
  52846. */
  52847. constructor(scene: Scene);
  52848. /**
  52849. * Registers the component in a given scene
  52850. */
  52851. register(): void;
  52852. /**
  52853. * Rebuilds the elements related to this component in case of
  52854. * context lost for instance.
  52855. */
  52856. rebuild(): void;
  52857. /**
  52858. * Disposes the component and the associated ressources
  52859. */
  52860. dispose(): void;
  52861. }
  52862. }
  52863. declare module BABYLON {
  52864. /**
  52865. * A helper for physics simulations
  52866. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  52867. */
  52868. export class PhysicsHelper {
  52869. private _scene;
  52870. private _physicsEngine;
  52871. /**
  52872. * Initializes the Physics helper
  52873. * @param scene Babylon.js scene
  52874. */
  52875. constructor(scene: Scene);
  52876. /**
  52877. * Applies a radial explosion impulse
  52878. * @param origin the origin of the explosion
  52879. * @param radiusOrEventOptions the radius or the options of radial explosion
  52880. * @param strength the explosion strength
  52881. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52882. * @returns A physics radial explosion event, or null
  52883. */
  52884. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52885. /**
  52886. * Applies a radial explosion force
  52887. * @param origin the origin of the explosion
  52888. * @param radiusOrEventOptions the radius or the options of radial explosion
  52889. * @param strength the explosion strength
  52890. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52891. * @returns A physics radial explosion event, or null
  52892. */
  52893. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  52894. /**
  52895. * Creates a gravitational field
  52896. * @param origin the origin of the explosion
  52897. * @param radiusOrEventOptions the radius or the options of radial explosion
  52898. * @param strength the explosion strength
  52899. * @param falloff possible options: Constant & Linear. Defaults to Constant
  52900. * @returns A physics gravitational field event, or null
  52901. */
  52902. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  52903. /**
  52904. * Creates a physics updraft event
  52905. * @param origin the origin of the updraft
  52906. * @param radiusOrEventOptions the radius or the options of the updraft
  52907. * @param strength the strength of the updraft
  52908. * @param height the height of the updraft
  52909. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  52910. * @returns A physics updraft event, or null
  52911. */
  52912. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  52913. /**
  52914. * Creates a physics vortex event
  52915. * @param origin the of the vortex
  52916. * @param radiusOrEventOptions the radius or the options of the vortex
  52917. * @param strength the strength of the vortex
  52918. * @param height the height of the vortex
  52919. * @returns a Physics vortex event, or null
  52920. * A physics vortex event or null
  52921. */
  52922. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  52923. }
  52924. /**
  52925. * Represents a physics radial explosion event
  52926. */
  52927. class PhysicsRadialExplosionEvent {
  52928. private _scene;
  52929. private _options;
  52930. private _sphere;
  52931. private _dataFetched;
  52932. /**
  52933. * Initializes a radial explosioin event
  52934. * @param _scene BabylonJS scene
  52935. * @param _options The options for the vortex event
  52936. */
  52937. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  52938. /**
  52939. * Returns the data related to the radial explosion event (sphere).
  52940. * @returns The radial explosion event data
  52941. */
  52942. getData(): PhysicsRadialExplosionEventData;
  52943. /**
  52944. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  52945. * @param impostor A physics imposter
  52946. * @param origin the origin of the explosion
  52947. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  52948. */
  52949. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  52950. /**
  52951. * Triggers affecterd impostors callbacks
  52952. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  52953. */
  52954. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  52955. /**
  52956. * Disposes the sphere.
  52957. * @param force Specifies if the sphere should be disposed by force
  52958. */
  52959. dispose(force?: boolean): void;
  52960. /*** Helpers ***/
  52961. private _prepareSphere;
  52962. private _intersectsWithSphere;
  52963. }
  52964. /**
  52965. * Represents a gravitational field event
  52966. */
  52967. class PhysicsGravitationalFieldEvent {
  52968. private _physicsHelper;
  52969. private _scene;
  52970. private _origin;
  52971. private _options;
  52972. private _tickCallback;
  52973. private _sphere;
  52974. private _dataFetched;
  52975. /**
  52976. * Initializes the physics gravitational field event
  52977. * @param _physicsHelper A physics helper
  52978. * @param _scene BabylonJS scene
  52979. * @param _origin The origin position of the gravitational field event
  52980. * @param _options The options for the vortex event
  52981. */
  52982. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  52983. /**
  52984. * Returns the data related to the gravitational field event (sphere).
  52985. * @returns A gravitational field event
  52986. */
  52987. getData(): PhysicsGravitationalFieldEventData;
  52988. /**
  52989. * Enables the gravitational field.
  52990. */
  52991. enable(): void;
  52992. /**
  52993. * Disables the gravitational field.
  52994. */
  52995. disable(): void;
  52996. /**
  52997. * Disposes the sphere.
  52998. * @param force The force to dispose from the gravitational field event
  52999. */
  53000. dispose(force?: boolean): void;
  53001. private _tick;
  53002. }
  53003. /**
  53004. * Represents a physics updraft event
  53005. */
  53006. class PhysicsUpdraftEvent {
  53007. private _scene;
  53008. private _origin;
  53009. private _options;
  53010. private _physicsEngine;
  53011. private _originTop;
  53012. private _originDirection;
  53013. private _tickCallback;
  53014. private _cylinder;
  53015. private _cylinderPosition;
  53016. private _dataFetched;
  53017. /**
  53018. * Initializes the physics updraft event
  53019. * @param _scene BabylonJS scene
  53020. * @param _origin The origin position of the updraft
  53021. * @param _options The options for the updraft event
  53022. */
  53023. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  53024. /**
  53025. * Returns the data related to the updraft event (cylinder).
  53026. * @returns A physics updraft event
  53027. */
  53028. getData(): PhysicsUpdraftEventData;
  53029. /**
  53030. * Enables the updraft.
  53031. */
  53032. enable(): void;
  53033. /**
  53034. * Disables the updraft.
  53035. */
  53036. disable(): void;
  53037. /**
  53038. * Disposes the cylinder.
  53039. * @param force Specifies if the updraft should be disposed by force
  53040. */
  53041. dispose(force?: boolean): void;
  53042. private getImpostorHitData;
  53043. private _tick;
  53044. /*** Helpers ***/
  53045. private _prepareCylinder;
  53046. private _intersectsWithCylinder;
  53047. }
  53048. /**
  53049. * Represents a physics vortex event
  53050. */
  53051. class PhysicsVortexEvent {
  53052. private _scene;
  53053. private _origin;
  53054. private _options;
  53055. private _physicsEngine;
  53056. private _originTop;
  53057. private _tickCallback;
  53058. private _cylinder;
  53059. private _cylinderPosition;
  53060. private _dataFetched;
  53061. /**
  53062. * Initializes the physics vortex event
  53063. * @param _scene The BabylonJS scene
  53064. * @param _origin The origin position of the vortex
  53065. * @param _options The options for the vortex event
  53066. */
  53067. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  53068. /**
  53069. * Returns the data related to the vortex event (cylinder).
  53070. * @returns The physics vortex event data
  53071. */
  53072. getData(): PhysicsVortexEventData;
  53073. /**
  53074. * Enables the vortex.
  53075. */
  53076. enable(): void;
  53077. /**
  53078. * Disables the cortex.
  53079. */
  53080. disable(): void;
  53081. /**
  53082. * Disposes the sphere.
  53083. * @param force
  53084. */
  53085. dispose(force?: boolean): void;
  53086. private getImpostorHitData;
  53087. private _tick;
  53088. /*** Helpers ***/
  53089. private _prepareCylinder;
  53090. private _intersectsWithCylinder;
  53091. }
  53092. /**
  53093. * Options fot the radial explosion event
  53094. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53095. */
  53096. export class PhysicsRadialExplosionEventOptions {
  53097. /**
  53098. * The radius of the sphere for the radial explosion.
  53099. */
  53100. radius: number;
  53101. /**
  53102. * The strenth of the explosion.
  53103. */
  53104. strength: number;
  53105. /**
  53106. * The strenght of the force in correspondence to the distance of the affected object
  53107. */
  53108. falloff: PhysicsRadialImpulseFalloff;
  53109. /**
  53110. * Sphere options for the radial explosion.
  53111. */
  53112. sphere: {
  53113. segments: number;
  53114. diameter: number;
  53115. };
  53116. /**
  53117. * Sphere options for the radial explosion.
  53118. */
  53119. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  53120. }
  53121. /**
  53122. * Options fot the updraft event
  53123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53124. */
  53125. export class PhysicsUpdraftEventOptions {
  53126. /**
  53127. * The radius of the cylinder for the vortex
  53128. */
  53129. radius: number;
  53130. /**
  53131. * The strenth of the updraft.
  53132. */
  53133. strength: number;
  53134. /**
  53135. * The height of the cylinder for the updraft.
  53136. */
  53137. height: number;
  53138. /**
  53139. * The mode for the the updraft.
  53140. */
  53141. updraftMode: PhysicsUpdraftMode;
  53142. }
  53143. /**
  53144. * Options fot the vortex event
  53145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53146. */
  53147. export class PhysicsVortexEventOptions {
  53148. /**
  53149. * The radius of the cylinder for the vortex
  53150. */
  53151. radius: number;
  53152. /**
  53153. * The strenth of the vortex.
  53154. */
  53155. strength: number;
  53156. /**
  53157. * The height of the cylinder for the vortex.
  53158. */
  53159. height: number;
  53160. /**
  53161. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  53162. */
  53163. centripetalForceThreshold: number;
  53164. /**
  53165. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  53166. */
  53167. centripetalForceMultiplier: number;
  53168. /**
  53169. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  53170. */
  53171. centrifugalForceMultiplier: number;
  53172. /**
  53173. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  53174. */
  53175. updraftForceMultiplier: number;
  53176. }
  53177. /**
  53178. * The strenght of the force in correspondence to the distance of the affected object
  53179. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53180. */
  53181. export enum PhysicsRadialImpulseFalloff {
  53182. /** Defines that impulse is constant in strength across it's whole radius */
  53183. Constant = 0,
  53184. /** Defines that impulse gets weaker if it's further from the origin */
  53185. Linear = 1
  53186. }
  53187. /**
  53188. * The strength of the force in correspondence to the distance of the affected object
  53189. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53190. */
  53191. export enum PhysicsUpdraftMode {
  53192. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  53193. Center = 0,
  53194. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  53195. Perpendicular = 1
  53196. }
  53197. /**
  53198. * Interface for a physics hit data
  53199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53200. */
  53201. export interface PhysicsHitData {
  53202. /**
  53203. * The force applied at the contact point
  53204. */
  53205. force: Vector3;
  53206. /**
  53207. * The contact point
  53208. */
  53209. contactPoint: Vector3;
  53210. /**
  53211. * The distance from the origin to the contact point
  53212. */
  53213. distanceFromOrigin: number;
  53214. }
  53215. /**
  53216. * Interface for radial explosion event data
  53217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53218. */
  53219. export interface PhysicsRadialExplosionEventData {
  53220. /**
  53221. * A sphere used for the radial explosion event
  53222. */
  53223. sphere: Mesh;
  53224. }
  53225. /**
  53226. * Interface for gravitational field event data
  53227. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53228. */
  53229. export interface PhysicsGravitationalFieldEventData {
  53230. /**
  53231. * A sphere mesh used for the gravitational field event
  53232. */
  53233. sphere: Mesh;
  53234. }
  53235. /**
  53236. * Interface for updraft event data
  53237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53238. */
  53239. export interface PhysicsUpdraftEventData {
  53240. /**
  53241. * A cylinder used for the updraft event
  53242. */
  53243. cylinder: Mesh;
  53244. }
  53245. /**
  53246. * Interface for vortex event data
  53247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53248. */
  53249. export interface PhysicsVortexEventData {
  53250. /**
  53251. * A cylinder used for the vortex event
  53252. */
  53253. cylinder: Mesh;
  53254. }
  53255. /**
  53256. * Interface for an affected physics impostor
  53257. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53258. */
  53259. export interface PhysicsAffectedImpostorWithData {
  53260. /**
  53261. * The impostor affected by the effect
  53262. */
  53263. impostor: PhysicsImpostor;
  53264. /**
  53265. * The data about the hit/horce from the explosion
  53266. */
  53267. hitData: PhysicsHitData;
  53268. }
  53269. }
  53270. declare module BABYLON {
  53271. /** @hidden */
  53272. export var blackAndWhitePixelShader: {
  53273. name: string;
  53274. shader: string;
  53275. };
  53276. }
  53277. declare module BABYLON {
  53278. /**
  53279. * Post process used to render in black and white
  53280. */
  53281. export class BlackAndWhitePostProcess extends PostProcess {
  53282. /**
  53283. * Linear about to convert he result to black and white (default: 1)
  53284. */
  53285. degree: number;
  53286. /**
  53287. * Creates a black and white post process
  53288. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  53289. * @param name The name of the effect.
  53290. * @param options The required width/height ratio to downsize to before computing the render pass.
  53291. * @param camera The camera to apply the render pass to.
  53292. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53293. * @param engine The engine which the post process will be applied. (default: current engine)
  53294. * @param reusable If the post process can be reused on the same frame. (default: false)
  53295. */
  53296. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53297. }
  53298. }
  53299. declare module BABYLON {
  53300. /**
  53301. * This represents a set of one or more post processes in Babylon.
  53302. * A post process can be used to apply a shader to a texture after it is rendered.
  53303. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  53304. */
  53305. export class PostProcessRenderEffect {
  53306. private _postProcesses;
  53307. private _getPostProcesses;
  53308. private _singleInstance;
  53309. private _cameras;
  53310. private _indicesForCamera;
  53311. /**
  53312. * Name of the effect
  53313. * @hidden
  53314. */ private _name: string;
  53315. /**
  53316. * Instantiates a post process render effect.
  53317. * A post process can be used to apply a shader to a texture after it is rendered.
  53318. * @param engine The engine the effect is tied to
  53319. * @param name The name of the effect
  53320. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  53321. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  53322. */
  53323. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  53324. /**
  53325. * Checks if all the post processes in the effect are supported.
  53326. */
  53327. readonly isSupported: boolean;
  53328. /**
  53329. * Updates the current state of the effect
  53330. * @hidden
  53331. */ private _update(): void;
  53332. /**
  53333. * Attaches the effect on cameras
  53334. * @param cameras The camera to attach to.
  53335. * @hidden
  53336. */ private _attachCameras(cameras: Camera): void;
  53337. /**
  53338. * Attaches the effect on cameras
  53339. * @param cameras The camera to attach to.
  53340. * @hidden
  53341. */ private _attachCameras(cameras: Camera[]): void;
  53342. /**
  53343. * Detaches the effect on cameras
  53344. * @param cameras The camera to detatch from.
  53345. * @hidden
  53346. */ private _detachCameras(cameras: Camera): void;
  53347. /**
  53348. * Detatches the effect on cameras
  53349. * @param cameras The camera to detatch from.
  53350. * @hidden
  53351. */ private _detachCameras(cameras: Camera[]): void;
  53352. /**
  53353. * Enables the effect on given cameras
  53354. * @param cameras The camera to enable.
  53355. * @hidden
  53356. */ private _enable(cameras: Camera): void;
  53357. /**
  53358. * Enables the effect on given cameras
  53359. * @param cameras The camera to enable.
  53360. * @hidden
  53361. */ private _enable(cameras: Nullable<Camera[]>): void;
  53362. /**
  53363. * Disables the effect on the given cameras
  53364. * @param cameras The camera to disable.
  53365. * @hidden
  53366. */ private _disable(cameras: Camera): void;
  53367. /**
  53368. * Disables the effect on the given cameras
  53369. * @param cameras The camera to disable.
  53370. * @hidden
  53371. */ private _disable(cameras: Nullable<Camera[]>): void;
  53372. /**
  53373. * Gets a list of the post processes contained in the effect.
  53374. * @param camera The camera to get the post processes on.
  53375. * @returns The list of the post processes in the effect.
  53376. */
  53377. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  53378. }
  53379. }
  53380. declare module BABYLON {
  53381. /** @hidden */
  53382. export var extractHighlightsPixelShader: {
  53383. name: string;
  53384. shader: string;
  53385. };
  53386. }
  53387. declare module BABYLON {
  53388. /**
  53389. * 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.
  53390. */
  53391. export class ExtractHighlightsPostProcess extends PostProcess {
  53392. /**
  53393. * The luminance threshold, pixels below this value will be set to black.
  53394. */
  53395. threshold: number;
  53396. /** @hidden */ private _exposure: number;
  53397. /**
  53398. * Post process which has the input texture to be used when performing highlight extraction
  53399. * @hidden
  53400. */ private _inputPostProcess: Nullable<PostProcess>;
  53401. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53402. }
  53403. }
  53404. declare module BABYLON {
  53405. /** @hidden */
  53406. export var bloomMergePixelShader: {
  53407. name: string;
  53408. shader: string;
  53409. };
  53410. }
  53411. declare module BABYLON {
  53412. /**
  53413. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53414. */
  53415. export class BloomMergePostProcess extends PostProcess {
  53416. /** Weight of the bloom to be added to the original input. */
  53417. weight: number;
  53418. /**
  53419. * Creates a new instance of @see BloomMergePostProcess
  53420. * @param name The name of the effect.
  53421. * @param originalFromInput Post process which's input will be used for the merge.
  53422. * @param blurred Blurred highlights post process which's output will be used.
  53423. * @param weight Weight of the bloom to be added to the original input.
  53424. * @param options The required width/height ratio to downsize to before computing the render pass.
  53425. * @param camera The camera to apply the render pass to.
  53426. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53427. * @param engine The engine which the post process will be applied. (default: current engine)
  53428. * @param reusable If the post process can be reused on the same frame. (default: false)
  53429. * @param textureType Type of textures used when performing the post process. (default: 0)
  53430. * @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)
  53431. */
  53432. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  53433. /** Weight of the bloom to be added to the original input. */
  53434. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53435. }
  53436. }
  53437. declare module BABYLON {
  53438. /**
  53439. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  53440. */
  53441. export class BloomEffect extends PostProcessRenderEffect {
  53442. private bloomScale;
  53443. /**
  53444. * @hidden Internal
  53445. */ private _effects: Array<PostProcess>;
  53446. /**
  53447. * @hidden Internal
  53448. */ private _downscale: ExtractHighlightsPostProcess;
  53449. private _blurX;
  53450. private _blurY;
  53451. private _merge;
  53452. /**
  53453. * The luminance threshold to find bright areas of the image to bloom.
  53454. */
  53455. threshold: number;
  53456. /**
  53457. * The strength of the bloom.
  53458. */
  53459. weight: number;
  53460. /**
  53461. * Specifies the size of the bloom blur kernel, relative to the final output size
  53462. */
  53463. kernel: number;
  53464. /**
  53465. * Creates a new instance of @see BloomEffect
  53466. * @param scene The scene the effect belongs to.
  53467. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  53468. * @param bloomKernel The size of the kernel to be used when applying the blur.
  53469. * @param bloomWeight The the strength of bloom.
  53470. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53471. * @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)
  53472. */
  53473. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  53474. /**
  53475. * Disposes each of the internal effects for a given camera.
  53476. * @param camera The camera to dispose the effect on.
  53477. */
  53478. disposeEffects(camera: Camera): void;
  53479. /**
  53480. * @hidden Internal
  53481. */ private _updateEffects(): void;
  53482. /**
  53483. * Internal
  53484. * @returns if all the contained post processes are ready.
  53485. * @hidden
  53486. */ private _isReady(): boolean;
  53487. }
  53488. }
  53489. declare module BABYLON {
  53490. /** @hidden */
  53491. export var chromaticAberrationPixelShader: {
  53492. name: string;
  53493. shader: string;
  53494. };
  53495. }
  53496. declare module BABYLON {
  53497. /**
  53498. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  53499. */
  53500. export class ChromaticAberrationPostProcess extends PostProcess {
  53501. /**
  53502. * The amount of seperation of rgb channels (default: 30)
  53503. */
  53504. aberrationAmount: number;
  53505. /**
  53506. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  53507. */
  53508. radialIntensity: number;
  53509. /**
  53510. * 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))
  53511. */
  53512. direction: Vector2;
  53513. /**
  53514. * 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))
  53515. */
  53516. centerPosition: Vector2;
  53517. /**
  53518. * Creates a new instance ChromaticAberrationPostProcess
  53519. * @param name The name of the effect.
  53520. * @param screenWidth The width of the screen to apply the effect on.
  53521. * @param screenHeight The height of the screen to apply the effect on.
  53522. * @param options The required width/height ratio to downsize to before computing the render pass.
  53523. * @param camera The camera to apply the render pass to.
  53524. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53525. * @param engine The engine which the post process will be applied. (default: current engine)
  53526. * @param reusable If the post process can be reused on the same frame. (default: false)
  53527. * @param textureType Type of textures used when performing the post process. (default: 0)
  53528. * @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)
  53529. */
  53530. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53531. }
  53532. }
  53533. declare module BABYLON {
  53534. /** @hidden */
  53535. export var circleOfConfusionPixelShader: {
  53536. name: string;
  53537. shader: string;
  53538. };
  53539. }
  53540. declare module BABYLON {
  53541. /**
  53542. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  53543. */
  53544. export class CircleOfConfusionPostProcess extends PostProcess {
  53545. /**
  53546. * 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.
  53547. */
  53548. lensSize: number;
  53549. /**
  53550. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53551. */
  53552. fStop: number;
  53553. /**
  53554. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53555. */
  53556. focusDistance: number;
  53557. /**
  53558. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  53559. */
  53560. focalLength: number;
  53561. private _depthTexture;
  53562. /**
  53563. * Creates a new instance CircleOfConfusionPostProcess
  53564. * @param name The name of the effect.
  53565. * @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.
  53566. * @param options The required width/height ratio to downsize to before computing the render pass.
  53567. * @param camera The camera to apply the render pass to.
  53568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53569. * @param engine The engine which the post process will be applied. (default: current engine)
  53570. * @param reusable If the post process can be reused on the same frame. (default: false)
  53571. * @param textureType Type of textures used when performing the post process. (default: 0)
  53572. * @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)
  53573. */
  53574. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53575. /**
  53576. * 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.
  53577. */
  53578. depthTexture: RenderTargetTexture;
  53579. }
  53580. }
  53581. declare module BABYLON {
  53582. /** @hidden */
  53583. export var colorCorrectionPixelShader: {
  53584. name: string;
  53585. shader: string;
  53586. };
  53587. }
  53588. declare module BABYLON {
  53589. /**
  53590. *
  53591. * This post-process allows the modification of rendered colors by using
  53592. * a 'look-up table' (LUT). This effect is also called Color Grading.
  53593. *
  53594. * The object needs to be provided an url to a texture containing the color
  53595. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  53596. * Use an image editing software to tweak the LUT to match your needs.
  53597. *
  53598. * For an example of a color LUT, see here:
  53599. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  53600. * For explanations on color grading, see here:
  53601. * @see http://udn.epicgames.com/Three/ColorGrading.html
  53602. *
  53603. */
  53604. export class ColorCorrectionPostProcess extends PostProcess {
  53605. private _colorTableTexture;
  53606. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53607. }
  53608. }
  53609. declare module BABYLON {
  53610. /** @hidden */
  53611. export var convolutionPixelShader: {
  53612. name: string;
  53613. shader: string;
  53614. };
  53615. }
  53616. declare module BABYLON {
  53617. /**
  53618. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  53619. * input texture to perform effects such as edge detection or sharpening
  53620. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  53621. */
  53622. export class ConvolutionPostProcess extends PostProcess {
  53623. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53624. kernel: number[];
  53625. /**
  53626. * Creates a new instance ConvolutionPostProcess
  53627. * @param name The name of the effect.
  53628. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  53629. * @param options The required width/height ratio to downsize to before computing the render pass.
  53630. * @param camera The camera to apply the render pass to.
  53631. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53632. * @param engine The engine which the post process will be applied. (default: current engine)
  53633. * @param reusable If the post process can be reused on the same frame. (default: false)
  53634. * @param textureType Type of textures used when performing the post process. (default: 0)
  53635. */
  53636. constructor(name: string,
  53637. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  53638. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53639. /**
  53640. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53641. */
  53642. static EdgeDetect0Kernel: number[];
  53643. /**
  53644. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53645. */
  53646. static EdgeDetect1Kernel: number[];
  53647. /**
  53648. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53649. */
  53650. static EdgeDetect2Kernel: number[];
  53651. /**
  53652. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53653. */
  53654. static SharpenKernel: number[];
  53655. /**
  53656. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53657. */
  53658. static EmbossKernel: number[];
  53659. /**
  53660. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  53661. */
  53662. static GaussianKernel: number[];
  53663. }
  53664. }
  53665. declare module BABYLON {
  53666. /**
  53667. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  53668. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  53669. * based on samples that have a large difference in distance than the center pixel.
  53670. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  53671. */
  53672. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  53673. direction: Vector2;
  53674. /**
  53675. * Creates a new instance CircleOfConfusionPostProcess
  53676. * @param name The name of the effect.
  53677. * @param scene The scene the effect belongs to.
  53678. * @param direction The direction the blur should be applied.
  53679. * @param kernel The size of the kernel used to blur.
  53680. * @param options The required width/height ratio to downsize to before computing the render pass.
  53681. * @param camera The camera to apply the render pass to.
  53682. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  53683. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  53684. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53685. * @param engine The engine which the post process will be applied. (default: current engine)
  53686. * @param reusable If the post process can be reused on the same frame. (default: false)
  53687. * @param textureType Type of textures used when performing the post process. (default: 0)
  53688. * @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)
  53689. */
  53690. 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);
  53691. }
  53692. }
  53693. declare module BABYLON {
  53694. /** @hidden */
  53695. export var depthOfFieldMergePixelShader: {
  53696. name: string;
  53697. shader: string;
  53698. };
  53699. }
  53700. declare module BABYLON {
  53701. /**
  53702. * Options to be set when merging outputs from the default pipeline.
  53703. */
  53704. export class DepthOfFieldMergePostProcessOptions {
  53705. /**
  53706. * The original image to merge on top of
  53707. */
  53708. originalFromInput: PostProcess;
  53709. /**
  53710. * Parameters to perform the merge of the depth of field effect
  53711. */
  53712. depthOfField?: {
  53713. circleOfConfusion: PostProcess;
  53714. blurSteps: Array<PostProcess>;
  53715. };
  53716. /**
  53717. * Parameters to perform the merge of bloom effect
  53718. */
  53719. bloom?: {
  53720. blurred: PostProcess;
  53721. weight: number;
  53722. };
  53723. }
  53724. /**
  53725. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  53726. */
  53727. export class DepthOfFieldMergePostProcess extends PostProcess {
  53728. private blurSteps;
  53729. /**
  53730. * Creates a new instance of DepthOfFieldMergePostProcess
  53731. * @param name The name of the effect.
  53732. * @param originalFromInput Post process which's input will be used for the merge.
  53733. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  53734. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  53735. * @param options The required width/height ratio to downsize to before computing the render pass.
  53736. * @param camera The camera to apply the render pass to.
  53737. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53738. * @param engine The engine which the post process will be applied. (default: current engine)
  53739. * @param reusable If the post process can be reused on the same frame. (default: false)
  53740. * @param textureType Type of textures used when performing the post process. (default: 0)
  53741. * @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)
  53742. */
  53743. 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);
  53744. /**
  53745. * Updates the effect with the current post process compile time values and recompiles the shader.
  53746. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  53747. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  53748. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  53749. * @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
  53750. * @param onCompiled Called when the shader has been compiled.
  53751. * @param onError Called if there is an error when compiling a shader.
  53752. */
  53753. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  53754. }
  53755. }
  53756. declare module BABYLON {
  53757. /**
  53758. * Specifies the level of max blur that should be applied when using the depth of field effect
  53759. */
  53760. export enum DepthOfFieldEffectBlurLevel {
  53761. /**
  53762. * Subtle blur
  53763. */
  53764. Low = 0,
  53765. /**
  53766. * Medium blur
  53767. */
  53768. Medium = 1,
  53769. /**
  53770. * Large blur
  53771. */
  53772. High = 2
  53773. }
  53774. /**
  53775. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  53776. */
  53777. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  53778. private _circleOfConfusion;
  53779. /**
  53780. * @hidden Internal, blurs from high to low
  53781. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  53782. private _depthOfFieldBlurY;
  53783. private _dofMerge;
  53784. /**
  53785. * @hidden Internal post processes in depth of field effect
  53786. */ private _effects: Array<PostProcess>;
  53787. /**
  53788. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  53789. */
  53790. focalLength: number;
  53791. /**
  53792. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  53793. */
  53794. fStop: number;
  53795. /**
  53796. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  53797. */
  53798. focusDistance: number;
  53799. /**
  53800. * 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.
  53801. */
  53802. lensSize: number;
  53803. /**
  53804. * Creates a new instance DepthOfFieldEffect
  53805. * @param scene The scene the effect belongs to.
  53806. * @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.
  53807. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  53808. * @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)
  53809. */
  53810. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  53811. /**
  53812. * Get the current class name of the current effet
  53813. * @returns "DepthOfFieldEffect"
  53814. */
  53815. getClassName(): string;
  53816. /**
  53817. * 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.
  53818. */
  53819. depthTexture: RenderTargetTexture;
  53820. /**
  53821. * Disposes each of the internal effects for a given camera.
  53822. * @param camera The camera to dispose the effect on.
  53823. */
  53824. disposeEffects(camera: Camera): void;
  53825. /**
  53826. * @hidden Internal
  53827. */ private _updateEffects(): void;
  53828. /**
  53829. * Internal
  53830. * @returns if all the contained post processes are ready.
  53831. * @hidden
  53832. */ private _isReady(): boolean;
  53833. }
  53834. }
  53835. declare module BABYLON {
  53836. /** @hidden */
  53837. export var displayPassPixelShader: {
  53838. name: string;
  53839. shader: string;
  53840. };
  53841. }
  53842. declare module BABYLON {
  53843. /**
  53844. * DisplayPassPostProcess which produces an output the same as it's input
  53845. */
  53846. export class DisplayPassPostProcess extends PostProcess {
  53847. /**
  53848. * Creates the DisplayPassPostProcess
  53849. * @param name The name of the effect.
  53850. * @param options The required width/height ratio to downsize to before computing the render pass.
  53851. * @param camera The camera to apply the render pass to.
  53852. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53853. * @param engine The engine which the post process will be applied. (default: current engine)
  53854. * @param reusable If the post process can be reused on the same frame. (default: false)
  53855. */
  53856. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53857. }
  53858. }
  53859. declare module BABYLON {
  53860. /** @hidden */
  53861. export var filterPixelShader: {
  53862. name: string;
  53863. shader: string;
  53864. };
  53865. }
  53866. declare module BABYLON {
  53867. /**
  53868. * Applies a kernel filter to the image
  53869. */
  53870. export class FilterPostProcess extends PostProcess {
  53871. /** The matrix to be applied to the image */
  53872. kernelMatrix: Matrix;
  53873. /**
  53874. *
  53875. * @param name The name of the effect.
  53876. * @param kernelMatrix The matrix to be applied to the image
  53877. * @param options The required width/height ratio to downsize to before computing the render pass.
  53878. * @param camera The camera to apply the render pass to.
  53879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53880. * @param engine The engine which the post process will be applied. (default: current engine)
  53881. * @param reusable If the post process can be reused on the same frame. (default: false)
  53882. */
  53883. constructor(name: string,
  53884. /** The matrix to be applied to the image */
  53885. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  53886. }
  53887. }
  53888. declare module BABYLON {
  53889. /** @hidden */
  53890. export var fxaaPixelShader: {
  53891. name: string;
  53892. shader: string;
  53893. };
  53894. }
  53895. declare module BABYLON {
  53896. /** @hidden */
  53897. export var fxaaVertexShader: {
  53898. name: string;
  53899. shader: string;
  53900. };
  53901. }
  53902. declare module BABYLON {
  53903. /**
  53904. * Fxaa post process
  53905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  53906. */
  53907. export class FxaaPostProcess extends PostProcess {
  53908. /** @hidden */
  53909. texelWidth: number;
  53910. /** @hidden */
  53911. texelHeight: number;
  53912. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53913. private _getDefines;
  53914. }
  53915. }
  53916. declare module BABYLON {
  53917. /** @hidden */
  53918. export var grainPixelShader: {
  53919. name: string;
  53920. shader: string;
  53921. };
  53922. }
  53923. declare module BABYLON {
  53924. /**
  53925. * The GrainPostProcess adds noise to the image at mid luminance levels
  53926. */
  53927. export class GrainPostProcess extends PostProcess {
  53928. /**
  53929. * The intensity of the grain added (default: 30)
  53930. */
  53931. intensity: number;
  53932. /**
  53933. * If the grain should be randomized on every frame
  53934. */
  53935. animated: boolean;
  53936. /**
  53937. * Creates a new instance of @see GrainPostProcess
  53938. * @param name The name of the effect.
  53939. * @param options The required width/height ratio to downsize to before computing the render pass.
  53940. * @param camera The camera to apply the render pass to.
  53941. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53942. * @param engine The engine which the post process will be applied. (default: current engine)
  53943. * @param reusable If the post process can be reused on the same frame. (default: false)
  53944. * @param textureType Type of textures used when performing the post process. (default: 0)
  53945. * @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)
  53946. */
  53947. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  53948. }
  53949. }
  53950. declare module BABYLON {
  53951. /** @hidden */
  53952. export var highlightsPixelShader: {
  53953. name: string;
  53954. shader: string;
  53955. };
  53956. }
  53957. declare module BABYLON {
  53958. /**
  53959. * Extracts highlights from the image
  53960. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53961. */
  53962. export class HighlightsPostProcess extends PostProcess {
  53963. /**
  53964. * Extracts highlights from the image
  53965. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  53966. * @param name The name of the effect.
  53967. * @param options The required width/height ratio to downsize to before computing the render pass.
  53968. * @param camera The camera to apply the render pass to.
  53969. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  53970. * @param engine The engine which the post process will be applied. (default: current engine)
  53971. * @param reusable If the post process can be reused on the same frame. (default: false)
  53972. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  53973. */
  53974. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  53975. }
  53976. }
  53977. declare module BABYLON {
  53978. /** @hidden */
  53979. export var mrtFragmentDeclaration: {
  53980. name: string;
  53981. shader: string;
  53982. };
  53983. }
  53984. declare module BABYLON {
  53985. /** @hidden */
  53986. export var geometryPixelShader: {
  53987. name: string;
  53988. shader: string;
  53989. };
  53990. }
  53991. declare module BABYLON {
  53992. /** @hidden */
  53993. export var geometryVertexShader: {
  53994. name: string;
  53995. shader: string;
  53996. };
  53997. }
  53998. declare module BABYLON {
  53999. /** @hidden */
  54000. interface ISavedTransformationMatrix {
  54001. world: Matrix;
  54002. viewProjection: Matrix;
  54003. }
  54004. /**
  54005. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  54006. */
  54007. export class GeometryBufferRenderer {
  54008. /**
  54009. * Constant used to retrieve the position texture index in the G-Buffer textures array
  54010. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  54011. */
  54012. static readonly POSITION_TEXTURE_TYPE: number;
  54013. /**
  54014. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  54015. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  54016. */
  54017. static readonly VELOCITY_TEXTURE_TYPE: number;
  54018. /**
  54019. * Dictionary used to store the previous transformation matrices of each rendered mesh
  54020. * in order to compute objects velocities when enableVelocity is set to "true"
  54021. * @hidden
  54022. */ private _previousTransformationMatrices: {
  54023. [index: number]: ISavedTransformationMatrix;
  54024. };
  54025. /**
  54026. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  54027. * in order to compute objects velocities when enableVelocity is set to "true"
  54028. * @hidden
  54029. */ private _previousBonesTransformationMatrices: {
  54030. [index: number]: Float32Array;
  54031. };
  54032. /**
  54033. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  54034. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  54035. */
  54036. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  54037. private _scene;
  54038. private _multiRenderTarget;
  54039. private _ratio;
  54040. private _enablePosition;
  54041. private _enableVelocity;
  54042. private _positionIndex;
  54043. private _velocityIndex;
  54044. protected _effect: Effect;
  54045. protected _cachedDefines: string;
  54046. /**
  54047. * Set the render list (meshes to be rendered) used in the G buffer.
  54048. */
  54049. renderList: Mesh[];
  54050. /**
  54051. * Gets wether or not G buffer are supported by the running hardware.
  54052. * This requires draw buffer supports
  54053. */
  54054. readonly isSupported: boolean;
  54055. /**
  54056. * Returns the index of the given texture type in the G-Buffer textures array
  54057. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  54058. * @returns the index of the given texture type in the G-Buffer textures array
  54059. */
  54060. getTextureIndex(textureType: number): number;
  54061. /**
  54062. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  54063. */
  54064. /**
  54065. * Sets whether or not objects positions are enabled for the G buffer.
  54066. */
  54067. enablePosition: boolean;
  54068. /**
  54069. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  54070. */
  54071. /**
  54072. * Sets wether or not objects velocities are enabled for the G buffer.
  54073. */
  54074. enableVelocity: boolean;
  54075. /**
  54076. * Gets the scene associated with the buffer.
  54077. */
  54078. readonly scene: Scene;
  54079. /**
  54080. * Gets the ratio used by the buffer during its creation.
  54081. * How big is the buffer related to the main canvas.
  54082. */
  54083. readonly ratio: number;
  54084. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  54085. /**
  54086. * Creates a new G Buffer for the scene
  54087. * @param scene The scene the buffer belongs to
  54088. * @param ratio How big is the buffer related to the main canvas.
  54089. */
  54090. constructor(scene: Scene, ratio?: number);
  54091. /**
  54092. * Checks wether everything is ready to render a submesh to the G buffer.
  54093. * @param subMesh the submesh to check readiness for
  54094. * @param useInstances is the mesh drawn using instance or not
  54095. * @returns true if ready otherwise false
  54096. */
  54097. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  54098. /**
  54099. * Gets the current underlying G Buffer.
  54100. * @returns the buffer
  54101. */
  54102. getGBuffer(): MultiRenderTarget;
  54103. /**
  54104. * Gets the number of samples used to render the buffer (anti aliasing).
  54105. */
  54106. /**
  54107. * Sets the number of samples used to render the buffer (anti aliasing).
  54108. */
  54109. samples: number;
  54110. /**
  54111. * Disposes the renderer and frees up associated resources.
  54112. */
  54113. dispose(): void;
  54114. protected _createRenderTargets(): void;
  54115. private _copyBonesTransformationMatrices;
  54116. }
  54117. }
  54118. declare module BABYLON {
  54119. interface Scene {
  54120. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54121. /**
  54122. * Gets or Sets the current geometry buffer associated to the scene.
  54123. */
  54124. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  54125. /**
  54126. * Enables a GeometryBufferRender and associates it with the scene
  54127. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  54128. * @returns the GeometryBufferRenderer
  54129. */
  54130. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  54131. /**
  54132. * Disables the GeometryBufferRender associated with the scene
  54133. */
  54134. disableGeometryBufferRenderer(): void;
  54135. }
  54136. /**
  54137. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  54138. * in several rendering techniques.
  54139. */
  54140. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  54141. /**
  54142. * The component name helpful to identify the component in the list of scene components.
  54143. */
  54144. readonly name: string;
  54145. /**
  54146. * The scene the component belongs to.
  54147. */
  54148. scene: Scene;
  54149. /**
  54150. * Creates a new instance of the component for the given scene
  54151. * @param scene Defines the scene to register the component in
  54152. */
  54153. constructor(scene: Scene);
  54154. /**
  54155. * Registers the component in a given scene
  54156. */
  54157. register(): void;
  54158. /**
  54159. * Rebuilds the elements related to this component in case of
  54160. * context lost for instance.
  54161. */
  54162. rebuild(): void;
  54163. /**
  54164. * Disposes the component and the associated ressources
  54165. */
  54166. dispose(): void;
  54167. private _gatherRenderTargets;
  54168. }
  54169. }
  54170. declare module BABYLON {
  54171. /** @hidden */
  54172. export var motionBlurPixelShader: {
  54173. name: string;
  54174. shader: string;
  54175. };
  54176. }
  54177. declare module BABYLON {
  54178. /**
  54179. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  54180. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  54181. * As an example, all you have to do is to create the post-process:
  54182. * var mb = new BABYLON.MotionBlurPostProcess(
  54183. * 'mb', // The name of the effect.
  54184. * scene, // The scene containing the objects to blur according to their velocity.
  54185. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  54186. * camera // The camera to apply the render pass to.
  54187. * );
  54188. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  54189. */
  54190. export class MotionBlurPostProcess extends PostProcess {
  54191. /**
  54192. * Defines how much the image is blurred by the movement. Default value is equal to 1
  54193. */
  54194. motionStrength: number;
  54195. /**
  54196. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  54197. */
  54198. /**
  54199. * Sets the number of iterations to be used for motion blur quality
  54200. */
  54201. motionBlurSamples: number;
  54202. private _motionBlurSamples;
  54203. private _geometryBufferRenderer;
  54204. /**
  54205. * Creates a new instance MotionBlurPostProcess
  54206. * @param name The name of the effect.
  54207. * @param scene The scene containing the objects to blur according to their velocity.
  54208. * @param options The required width/height ratio to downsize to before computing the render pass.
  54209. * @param camera The camera to apply the render pass to.
  54210. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54211. * @param engine The engine which the post process will be applied. (default: current engine)
  54212. * @param reusable If the post process can be reused on the same frame. (default: false)
  54213. * @param textureType Type of textures used when performing the post process. (default: 0)
  54214. * @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)
  54215. */
  54216. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54217. /**
  54218. * Excludes the given skinned mesh from computing bones velocities.
  54219. * Computing bones velocities can have a cost and that cost. The cost can be saved by calling this function and by passing the skinned mesh reference to ignore.
  54220. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  54221. */
  54222. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  54223. /**
  54224. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  54225. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  54226. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  54227. */
  54228. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  54229. /**
  54230. * Disposes the post process.
  54231. * @param camera The camera to dispose the post process on.
  54232. */
  54233. dispose(camera?: Camera): void;
  54234. }
  54235. }
  54236. declare module BABYLON {
  54237. /** @hidden */
  54238. export var refractionPixelShader: {
  54239. name: string;
  54240. shader: string;
  54241. };
  54242. }
  54243. declare module BABYLON {
  54244. /**
  54245. * Post process which applies a refractin texture
  54246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54247. */
  54248. export class RefractionPostProcess extends PostProcess {
  54249. /** the base color of the refraction (used to taint the rendering) */
  54250. color: Color3;
  54251. /** simulated refraction depth */
  54252. depth: number;
  54253. /** the coefficient of the base color (0 to remove base color tainting) */
  54254. colorLevel: number;
  54255. private _refTexture;
  54256. private _ownRefractionTexture;
  54257. /**
  54258. * Gets or sets the refraction texture
  54259. * Please note that you are responsible for disposing the texture if you set it manually
  54260. */
  54261. refractionTexture: Texture;
  54262. /**
  54263. * Initializes the RefractionPostProcess
  54264. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  54265. * @param name The name of the effect.
  54266. * @param refractionTextureUrl Url of the refraction texture to use
  54267. * @param color the base color of the refraction (used to taint the rendering)
  54268. * @param depth simulated refraction depth
  54269. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  54270. * @param camera The camera to apply the render pass to.
  54271. * @param options The required width/height ratio to downsize to before computing the render pass.
  54272. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54273. * @param engine The engine which the post process will be applied. (default: current engine)
  54274. * @param reusable If the post process can be reused on the same frame. (default: false)
  54275. */
  54276. constructor(name: string, refractionTextureUrl: string,
  54277. /** the base color of the refraction (used to taint the rendering) */
  54278. color: Color3,
  54279. /** simulated refraction depth */
  54280. depth: number,
  54281. /** the coefficient of the base color (0 to remove base color tainting) */
  54282. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54283. /**
  54284. * Disposes of the post process
  54285. * @param camera Camera to dispose post process on
  54286. */
  54287. dispose(camera: Camera): void;
  54288. }
  54289. }
  54290. declare module BABYLON {
  54291. /** @hidden */
  54292. export var sharpenPixelShader: {
  54293. name: string;
  54294. shader: string;
  54295. };
  54296. }
  54297. declare module BABYLON {
  54298. /**
  54299. * The SharpenPostProcess applies a sharpen kernel to every pixel
  54300. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54301. */
  54302. export class SharpenPostProcess extends PostProcess {
  54303. /**
  54304. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  54305. */
  54306. colorAmount: number;
  54307. /**
  54308. * How much sharpness should be applied (default: 0.3)
  54309. */
  54310. edgeAmount: number;
  54311. /**
  54312. * Creates a new instance ConvolutionPostProcess
  54313. * @param name The name of the effect.
  54314. * @param options The required width/height ratio to downsize to before computing the render pass.
  54315. * @param camera The camera to apply the render pass to.
  54316. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54317. * @param engine The engine which the post process will be applied. (default: current engine)
  54318. * @param reusable If the post process can be reused on the same frame. (default: false)
  54319. * @param textureType Type of textures used when performing the post process. (default: 0)
  54320. * @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)
  54321. */
  54322. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54323. }
  54324. }
  54325. declare module BABYLON {
  54326. /**
  54327. * PostProcessRenderPipeline
  54328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54329. */
  54330. export class PostProcessRenderPipeline {
  54331. private engine;
  54332. private _renderEffects;
  54333. private _renderEffectsForIsolatedPass;
  54334. /**
  54335. * List of inspectable custom properties (used by the Inspector)
  54336. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  54337. */
  54338. inspectableCustomProperties: IInspectable[];
  54339. /**
  54340. * @hidden
  54341. */
  54342. protected _cameras: Camera[];
  54343. /** @hidden */ private _name: string;
  54344. /**
  54345. * Gets pipeline name
  54346. */
  54347. readonly name: string;
  54348. /**
  54349. * Initializes a PostProcessRenderPipeline
  54350. * @param engine engine to add the pipeline to
  54351. * @param name name of the pipeline
  54352. */
  54353. constructor(engine: Engine, name: string);
  54354. /**
  54355. * Gets the class name
  54356. * @returns "PostProcessRenderPipeline"
  54357. */
  54358. getClassName(): string;
  54359. /**
  54360. * If all the render effects in the pipeline are supported
  54361. */
  54362. readonly isSupported: boolean;
  54363. /**
  54364. * Adds an effect to the pipeline
  54365. * @param renderEffect the effect to add
  54366. */
  54367. addEffect(renderEffect: PostProcessRenderEffect): void;
  54368. /** @hidden */ private _rebuild(): void;
  54369. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  54370. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  54371. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54372. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  54373. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  54374. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  54375. /** @hidden */ private _detachCameras(cameras: Camera): void;
  54376. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  54377. /** @hidden */ private _update(): void;
  54378. /** @hidden */ private _reset(): void;
  54379. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  54380. /**
  54381. * Disposes of the pipeline
  54382. */
  54383. dispose(): void;
  54384. }
  54385. }
  54386. declare module BABYLON {
  54387. /**
  54388. * PostProcessRenderPipelineManager class
  54389. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54390. */
  54391. export class PostProcessRenderPipelineManager {
  54392. private _renderPipelines;
  54393. /**
  54394. * Initializes a PostProcessRenderPipelineManager
  54395. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54396. */
  54397. constructor();
  54398. /**
  54399. * Gets the list of supported render pipelines
  54400. */
  54401. readonly supportedPipelines: PostProcessRenderPipeline[];
  54402. /**
  54403. * Adds a pipeline to the manager
  54404. * @param renderPipeline The pipeline to add
  54405. */
  54406. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  54407. /**
  54408. * Attaches a camera to the pipeline
  54409. * @param renderPipelineName The name of the pipeline to attach to
  54410. * @param cameras the camera to attach
  54411. * @param unique if the camera can be attached multiple times to the pipeline
  54412. */
  54413. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  54414. /**
  54415. * Detaches a camera from the pipeline
  54416. * @param renderPipelineName The name of the pipeline to detach from
  54417. * @param cameras the camera to detach
  54418. */
  54419. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  54420. /**
  54421. * Enables an effect by name on a pipeline
  54422. * @param renderPipelineName the name of the pipeline to enable the effect in
  54423. * @param renderEffectName the name of the effect to enable
  54424. * @param cameras the cameras that the effect should be enabled on
  54425. */
  54426. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54427. /**
  54428. * Disables an effect by name on a pipeline
  54429. * @param renderPipelineName the name of the pipeline to disable the effect in
  54430. * @param renderEffectName the name of the effect to disable
  54431. * @param cameras the cameras that the effect should be disabled on
  54432. */
  54433. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  54434. /**
  54435. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  54436. */
  54437. update(): void;
  54438. /** @hidden */ private _rebuild(): void;
  54439. /**
  54440. * Disposes of the manager and pipelines
  54441. */
  54442. dispose(): void;
  54443. }
  54444. }
  54445. declare module BABYLON {
  54446. interface Scene {
  54447. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54448. /**
  54449. * Gets the postprocess render pipeline manager
  54450. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54451. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54452. */
  54453. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  54454. }
  54455. /**
  54456. * Defines the Render Pipeline scene component responsible to rendering pipelines
  54457. */
  54458. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  54459. /**
  54460. * The component name helpfull to identify the component in the list of scene components.
  54461. */
  54462. readonly name: string;
  54463. /**
  54464. * The scene the component belongs to.
  54465. */
  54466. scene: Scene;
  54467. /**
  54468. * Creates a new instance of the component for the given scene
  54469. * @param scene Defines the scene to register the component in
  54470. */
  54471. constructor(scene: Scene);
  54472. /**
  54473. * Registers the component in a given scene
  54474. */
  54475. register(): void;
  54476. /**
  54477. * Rebuilds the elements related to this component in case of
  54478. * context lost for instance.
  54479. */
  54480. rebuild(): void;
  54481. /**
  54482. * Disposes the component and the associated ressources
  54483. */
  54484. dispose(): void;
  54485. private _gatherRenderTargets;
  54486. }
  54487. }
  54488. declare module BABYLON {
  54489. /**
  54490. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  54491. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  54492. */
  54493. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  54494. private _scene;
  54495. private _camerasToBeAttached;
  54496. /**
  54497. * ID of the sharpen post process,
  54498. */
  54499. private readonly SharpenPostProcessId;
  54500. /**
  54501. * @ignore
  54502. * ID of the image processing post process;
  54503. */
  54504. readonly ImageProcessingPostProcessId: string;
  54505. /**
  54506. * @ignore
  54507. * ID of the Fast Approximate Anti-Aliasing post process;
  54508. */
  54509. readonly FxaaPostProcessId: string;
  54510. /**
  54511. * ID of the chromatic aberration post process,
  54512. */
  54513. private readonly ChromaticAberrationPostProcessId;
  54514. /**
  54515. * ID of the grain post process
  54516. */
  54517. private readonly GrainPostProcessId;
  54518. /**
  54519. * Sharpen post process which will apply a sharpen convolution to enhance edges
  54520. */
  54521. sharpen: SharpenPostProcess;
  54522. private _sharpenEffect;
  54523. private bloom;
  54524. /**
  54525. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  54526. */
  54527. depthOfField: DepthOfFieldEffect;
  54528. /**
  54529. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  54530. */
  54531. fxaa: FxaaPostProcess;
  54532. /**
  54533. * Image post processing pass used to perform operations such as tone mapping or color grading.
  54534. */
  54535. imageProcessing: ImageProcessingPostProcess;
  54536. /**
  54537. * Chromatic aberration post process which will shift rgb colors in the image
  54538. */
  54539. chromaticAberration: ChromaticAberrationPostProcess;
  54540. private _chromaticAberrationEffect;
  54541. /**
  54542. * Grain post process which add noise to the image
  54543. */
  54544. grain: GrainPostProcess;
  54545. private _grainEffect;
  54546. /**
  54547. * Glow post process which adds a glow to emissive areas of the image
  54548. */
  54549. private _glowLayer;
  54550. /**
  54551. * Animations which can be used to tweak settings over a period of time
  54552. */
  54553. animations: Animation[];
  54554. private _imageProcessingConfigurationObserver;
  54555. private _sharpenEnabled;
  54556. private _bloomEnabled;
  54557. private _depthOfFieldEnabled;
  54558. private _depthOfFieldBlurLevel;
  54559. private _fxaaEnabled;
  54560. private _imageProcessingEnabled;
  54561. private _defaultPipelineTextureType;
  54562. private _bloomScale;
  54563. private _chromaticAberrationEnabled;
  54564. private _grainEnabled;
  54565. private _buildAllowed;
  54566. /**
  54567. * Gets active scene
  54568. */
  54569. readonly scene: Scene;
  54570. /**
  54571. * Enable or disable the sharpen process from the pipeline
  54572. */
  54573. sharpenEnabled: boolean;
  54574. private _resizeObserver;
  54575. private _hardwareScaleLevel;
  54576. private _bloomKernel;
  54577. /**
  54578. * Specifies the size of the bloom blur kernel, relative to the final output size
  54579. */
  54580. bloomKernel: number;
  54581. /**
  54582. * Specifies the weight of the bloom in the final rendering
  54583. */
  54584. private _bloomWeight;
  54585. /**
  54586. * Specifies the luma threshold for the area that will be blurred by the bloom
  54587. */
  54588. private _bloomThreshold;
  54589. private _hdr;
  54590. /**
  54591. * The strength of the bloom.
  54592. */
  54593. bloomWeight: number;
  54594. /**
  54595. * The strength of the bloom.
  54596. */
  54597. bloomThreshold: number;
  54598. /**
  54599. * The scale of the bloom, lower value will provide better performance.
  54600. */
  54601. bloomScale: number;
  54602. /**
  54603. * Enable or disable the bloom from the pipeline
  54604. */
  54605. bloomEnabled: boolean;
  54606. private _rebuildBloom;
  54607. /**
  54608. * If the depth of field is enabled.
  54609. */
  54610. depthOfFieldEnabled: boolean;
  54611. /**
  54612. * Blur level of the depth of field effect. (Higher blur will effect performance)
  54613. */
  54614. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  54615. /**
  54616. * If the anti aliasing is enabled.
  54617. */
  54618. fxaaEnabled: boolean;
  54619. private _samples;
  54620. /**
  54621. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  54622. */
  54623. samples: number;
  54624. /**
  54625. * If image processing is enabled.
  54626. */
  54627. imageProcessingEnabled: boolean;
  54628. /**
  54629. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  54630. */
  54631. glowLayerEnabled: boolean;
  54632. /**
  54633. * Gets the glow layer (or null if not defined)
  54634. */
  54635. readonly glowLayer: Nullable<GlowLayer>;
  54636. /**
  54637. * Enable or disable the chromaticAberration process from the pipeline
  54638. */
  54639. chromaticAberrationEnabled: boolean;
  54640. /**
  54641. * Enable or disable the grain process from the pipeline
  54642. */
  54643. grainEnabled: boolean;
  54644. /**
  54645. * @constructor
  54646. * @param name - The rendering pipeline name (default: "")
  54647. * @param hdr - If high dynamic range textures should be used (default: true)
  54648. * @param scene - The scene linked to this pipeline (default: the last created scene)
  54649. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  54650. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  54651. */
  54652. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  54653. /**
  54654. * Get the class name
  54655. * @returns "DefaultRenderingPipeline"
  54656. */
  54657. getClassName(): string;
  54658. /**
  54659. * Force the compilation of the entire pipeline.
  54660. */
  54661. prepare(): void;
  54662. private _hasCleared;
  54663. private _prevPostProcess;
  54664. private _prevPrevPostProcess;
  54665. private _setAutoClearAndTextureSharing;
  54666. private _depthOfFieldSceneObserver;
  54667. private _buildPipeline;
  54668. private _disposePostProcesses;
  54669. /**
  54670. * Adds a camera to the pipeline
  54671. * @param camera the camera to be added
  54672. */
  54673. addCamera(camera: Camera): void;
  54674. /**
  54675. * Removes a camera from the pipeline
  54676. * @param camera the camera to remove
  54677. */
  54678. removeCamera(camera: Camera): void;
  54679. /**
  54680. * Dispose of the pipeline and stop all post processes
  54681. */
  54682. dispose(): void;
  54683. /**
  54684. * Serialize the rendering pipeline (Used when exporting)
  54685. * @returns the serialized object
  54686. */
  54687. serialize(): any;
  54688. /**
  54689. * Parse the serialized pipeline
  54690. * @param source Source pipeline.
  54691. * @param scene The scene to load the pipeline to.
  54692. * @param rootUrl The URL of the serialized pipeline.
  54693. * @returns An instantiated pipeline from the serialized object.
  54694. */
  54695. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  54696. }
  54697. }
  54698. declare module BABYLON {
  54699. /** @hidden */
  54700. export var lensHighlightsPixelShader: {
  54701. name: string;
  54702. shader: string;
  54703. };
  54704. }
  54705. declare module BABYLON {
  54706. /** @hidden */
  54707. export var depthOfFieldPixelShader: {
  54708. name: string;
  54709. shader: string;
  54710. };
  54711. }
  54712. declare module BABYLON {
  54713. /**
  54714. * BABYLON.JS Chromatic Aberration GLSL Shader
  54715. * Author: Olivier Guyot
  54716. * Separates very slightly R, G and B colors on the edges of the screen
  54717. * Inspired by Francois Tarlier & Martins Upitis
  54718. */
  54719. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  54720. /**
  54721. * @ignore
  54722. * The chromatic aberration PostProcess id in the pipeline
  54723. */
  54724. LensChromaticAberrationEffect: string;
  54725. /**
  54726. * @ignore
  54727. * The highlights enhancing PostProcess id in the pipeline
  54728. */
  54729. HighlightsEnhancingEffect: string;
  54730. /**
  54731. * @ignore
  54732. * The depth-of-field PostProcess id in the pipeline
  54733. */
  54734. LensDepthOfFieldEffect: string;
  54735. private _scene;
  54736. private _depthTexture;
  54737. private _grainTexture;
  54738. private _chromaticAberrationPostProcess;
  54739. private _highlightsPostProcess;
  54740. private _depthOfFieldPostProcess;
  54741. private _edgeBlur;
  54742. private _grainAmount;
  54743. private _chromaticAberration;
  54744. private _distortion;
  54745. private _highlightsGain;
  54746. private _highlightsThreshold;
  54747. private _dofDistance;
  54748. private _dofAperture;
  54749. private _dofDarken;
  54750. private _dofPentagon;
  54751. private _blurNoise;
  54752. /**
  54753. * @constructor
  54754. *
  54755. * Effect parameters are as follow:
  54756. * {
  54757. * chromatic_aberration: number; // from 0 to x (1 for realism)
  54758. * edge_blur: number; // from 0 to x (1 for realism)
  54759. * distortion: number; // from 0 to x (1 for realism)
  54760. * grain_amount: number; // from 0 to 1
  54761. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  54762. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  54763. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  54764. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  54765. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  54766. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  54767. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  54768. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  54769. * }
  54770. * Note: if an effect parameter is unset, effect is disabled
  54771. *
  54772. * @param name The rendering pipeline name
  54773. * @param parameters - An object containing all parameters (see above)
  54774. * @param scene The scene linked to this pipeline
  54775. * @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)
  54776. * @param cameras The array of cameras that the rendering pipeline will be attached to
  54777. */
  54778. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  54779. /**
  54780. * Get the class name
  54781. * @returns "LensRenderingPipeline"
  54782. */
  54783. getClassName(): string;
  54784. /**
  54785. * Gets associated scene
  54786. */
  54787. readonly scene: Scene;
  54788. /**
  54789. * Gets or sets the edge blur
  54790. */
  54791. edgeBlur: number;
  54792. /**
  54793. * Gets or sets the grain amount
  54794. */
  54795. grainAmount: number;
  54796. /**
  54797. * Gets or sets the chromatic aberration amount
  54798. */
  54799. chromaticAberration: number;
  54800. /**
  54801. * Gets or sets the depth of field aperture
  54802. */
  54803. dofAperture: number;
  54804. /**
  54805. * Gets or sets the edge distortion
  54806. */
  54807. edgeDistortion: number;
  54808. /**
  54809. * Gets or sets the depth of field distortion
  54810. */
  54811. dofDistortion: number;
  54812. /**
  54813. * Gets or sets the darken out of focus amount
  54814. */
  54815. darkenOutOfFocus: number;
  54816. /**
  54817. * Gets or sets a boolean indicating if blur noise is enabled
  54818. */
  54819. blurNoise: boolean;
  54820. /**
  54821. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  54822. */
  54823. pentagonBokeh: boolean;
  54824. /**
  54825. * Gets or sets the highlight grain amount
  54826. */
  54827. highlightsGain: number;
  54828. /**
  54829. * Gets or sets the highlight threshold
  54830. */
  54831. highlightsThreshold: number;
  54832. /**
  54833. * Sets the amount of blur at the edges
  54834. * @param amount blur amount
  54835. */
  54836. setEdgeBlur(amount: number): void;
  54837. /**
  54838. * Sets edge blur to 0
  54839. */
  54840. disableEdgeBlur(): void;
  54841. /**
  54842. * Sets the amout of grain
  54843. * @param amount Amount of grain
  54844. */
  54845. setGrainAmount(amount: number): void;
  54846. /**
  54847. * Set grain amount to 0
  54848. */
  54849. disableGrain(): void;
  54850. /**
  54851. * Sets the chromatic aberration amount
  54852. * @param amount amount of chromatic aberration
  54853. */
  54854. setChromaticAberration(amount: number): void;
  54855. /**
  54856. * Sets chromatic aberration amount to 0
  54857. */
  54858. disableChromaticAberration(): void;
  54859. /**
  54860. * Sets the EdgeDistortion amount
  54861. * @param amount amount of EdgeDistortion
  54862. */
  54863. setEdgeDistortion(amount: number): void;
  54864. /**
  54865. * Sets edge distortion to 0
  54866. */
  54867. disableEdgeDistortion(): void;
  54868. /**
  54869. * Sets the FocusDistance amount
  54870. * @param amount amount of FocusDistance
  54871. */
  54872. setFocusDistance(amount: number): void;
  54873. /**
  54874. * Disables depth of field
  54875. */
  54876. disableDepthOfField(): void;
  54877. /**
  54878. * Sets the Aperture amount
  54879. * @param amount amount of Aperture
  54880. */
  54881. setAperture(amount: number): void;
  54882. /**
  54883. * Sets the DarkenOutOfFocus amount
  54884. * @param amount amount of DarkenOutOfFocus
  54885. */
  54886. setDarkenOutOfFocus(amount: number): void;
  54887. private _pentagonBokehIsEnabled;
  54888. /**
  54889. * Creates a pentagon bokeh effect
  54890. */
  54891. enablePentagonBokeh(): void;
  54892. /**
  54893. * Disables the pentagon bokeh effect
  54894. */
  54895. disablePentagonBokeh(): void;
  54896. /**
  54897. * Enables noise blur
  54898. */
  54899. enableNoiseBlur(): void;
  54900. /**
  54901. * Disables noise blur
  54902. */
  54903. disableNoiseBlur(): void;
  54904. /**
  54905. * Sets the HighlightsGain amount
  54906. * @param amount amount of HighlightsGain
  54907. */
  54908. setHighlightsGain(amount: number): void;
  54909. /**
  54910. * Sets the HighlightsThreshold amount
  54911. * @param amount amount of HighlightsThreshold
  54912. */
  54913. setHighlightsThreshold(amount: number): void;
  54914. /**
  54915. * Disables highlights
  54916. */
  54917. disableHighlights(): void;
  54918. /**
  54919. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  54920. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  54921. */
  54922. dispose(disableDepthRender?: boolean): void;
  54923. private _createChromaticAberrationPostProcess;
  54924. private _createHighlightsPostProcess;
  54925. private _createDepthOfFieldPostProcess;
  54926. private _createGrainTexture;
  54927. }
  54928. }
  54929. declare module BABYLON {
  54930. /** @hidden */
  54931. export var ssao2PixelShader: {
  54932. name: string;
  54933. shader: string;
  54934. };
  54935. }
  54936. declare module BABYLON {
  54937. /** @hidden */
  54938. export var ssaoCombinePixelShader: {
  54939. name: string;
  54940. shader: string;
  54941. };
  54942. }
  54943. declare module BABYLON {
  54944. /**
  54945. * Render pipeline to produce ssao effect
  54946. */
  54947. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  54948. /**
  54949. * @ignore
  54950. * The PassPostProcess id in the pipeline that contains the original scene color
  54951. */
  54952. SSAOOriginalSceneColorEffect: string;
  54953. /**
  54954. * @ignore
  54955. * The SSAO PostProcess id in the pipeline
  54956. */
  54957. SSAORenderEffect: string;
  54958. /**
  54959. * @ignore
  54960. * The horizontal blur PostProcess id in the pipeline
  54961. */
  54962. SSAOBlurHRenderEffect: string;
  54963. /**
  54964. * @ignore
  54965. * The vertical blur PostProcess id in the pipeline
  54966. */
  54967. SSAOBlurVRenderEffect: string;
  54968. /**
  54969. * @ignore
  54970. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  54971. */
  54972. SSAOCombineRenderEffect: string;
  54973. /**
  54974. * The output strength of the SSAO post-process. Default value is 1.0.
  54975. */
  54976. totalStrength: number;
  54977. /**
  54978. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  54979. */
  54980. maxZ: number;
  54981. /**
  54982. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  54983. */
  54984. minZAspect: number;
  54985. private _samples;
  54986. /**
  54987. * Number of samples used for the SSAO calculations. Default value is 8
  54988. */
  54989. samples: number;
  54990. private _textureSamples;
  54991. /**
  54992. * Number of samples to use for antialiasing
  54993. */
  54994. textureSamples: number;
  54995. /**
  54996. * Ratio object used for SSAO ratio and blur ratio
  54997. */
  54998. private _ratio;
  54999. /**
  55000. * Dynamically generated sphere sampler.
  55001. */
  55002. private _sampleSphere;
  55003. /**
  55004. * Blur filter offsets
  55005. */
  55006. private _samplerOffsets;
  55007. private _expensiveBlur;
  55008. /**
  55009. * If bilateral blur should be used
  55010. */
  55011. expensiveBlur: boolean;
  55012. /**
  55013. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  55014. */
  55015. radius: number;
  55016. /**
  55017. * The base color of the SSAO post-process
  55018. * The final result is "base + ssao" between [0, 1]
  55019. */
  55020. base: number;
  55021. /**
  55022. * Support test.
  55023. */
  55024. static readonly IsSupported: boolean;
  55025. private _scene;
  55026. private _depthTexture;
  55027. private _normalTexture;
  55028. private _randomTexture;
  55029. private _originalColorPostProcess;
  55030. private _ssaoPostProcess;
  55031. private _blurHPostProcess;
  55032. private _blurVPostProcess;
  55033. private _ssaoCombinePostProcess;
  55034. private _firstUpdate;
  55035. /**
  55036. * Gets active scene
  55037. */
  55038. readonly scene: Scene;
  55039. /**
  55040. * @constructor
  55041. * @param name The rendering pipeline name
  55042. * @param scene The scene linked to this pipeline
  55043. * @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 }
  55044. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55045. */
  55046. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55047. /**
  55048. * Get the class name
  55049. * @returns "SSAO2RenderingPipeline"
  55050. */
  55051. getClassName(): string;
  55052. /**
  55053. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55054. */
  55055. dispose(disableGeometryBufferRenderer?: boolean): void;
  55056. private _createBlurPostProcess;
  55057. /** @hidden */ private _rebuild(): void;
  55058. private _bits;
  55059. private _radicalInverse_VdC;
  55060. private _hammersley;
  55061. private _hemisphereSample_uniform;
  55062. private _generateHemisphere;
  55063. private _createSSAOPostProcess;
  55064. private _createSSAOCombinePostProcess;
  55065. private _createRandomTexture;
  55066. /**
  55067. * Serialize the rendering pipeline (Used when exporting)
  55068. * @returns the serialized object
  55069. */
  55070. serialize(): any;
  55071. /**
  55072. * Parse the serialized pipeline
  55073. * @param source Source pipeline.
  55074. * @param scene The scene to load the pipeline to.
  55075. * @param rootUrl The URL of the serialized pipeline.
  55076. * @returns An instantiated pipeline from the serialized object.
  55077. */
  55078. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  55079. }
  55080. }
  55081. declare module BABYLON {
  55082. /** @hidden */
  55083. export var ssaoPixelShader: {
  55084. name: string;
  55085. shader: string;
  55086. };
  55087. }
  55088. declare module BABYLON {
  55089. /**
  55090. * Render pipeline to produce ssao effect
  55091. */
  55092. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  55093. /**
  55094. * @ignore
  55095. * The PassPostProcess id in the pipeline that contains the original scene color
  55096. */
  55097. SSAOOriginalSceneColorEffect: string;
  55098. /**
  55099. * @ignore
  55100. * The SSAO PostProcess id in the pipeline
  55101. */
  55102. SSAORenderEffect: string;
  55103. /**
  55104. * @ignore
  55105. * The horizontal blur PostProcess id in the pipeline
  55106. */
  55107. SSAOBlurHRenderEffect: string;
  55108. /**
  55109. * @ignore
  55110. * The vertical blur PostProcess id in the pipeline
  55111. */
  55112. SSAOBlurVRenderEffect: string;
  55113. /**
  55114. * @ignore
  55115. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  55116. */
  55117. SSAOCombineRenderEffect: string;
  55118. /**
  55119. * The output strength of the SSAO post-process. Default value is 1.0.
  55120. */
  55121. totalStrength: number;
  55122. /**
  55123. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  55124. */
  55125. radius: number;
  55126. /**
  55127. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  55128. * Must not be equal to fallOff and superior to fallOff.
  55129. * Default value is 0.0075
  55130. */
  55131. area: number;
  55132. /**
  55133. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  55134. * Must not be equal to area and inferior to area.
  55135. * Default value is 0.000001
  55136. */
  55137. fallOff: number;
  55138. /**
  55139. * The base color of the SSAO post-process
  55140. * The final result is "base + ssao" between [0, 1]
  55141. */
  55142. base: number;
  55143. private _scene;
  55144. private _depthTexture;
  55145. private _randomTexture;
  55146. private _originalColorPostProcess;
  55147. private _ssaoPostProcess;
  55148. private _blurHPostProcess;
  55149. private _blurVPostProcess;
  55150. private _ssaoCombinePostProcess;
  55151. private _firstUpdate;
  55152. /**
  55153. * Gets active scene
  55154. */
  55155. readonly scene: Scene;
  55156. /**
  55157. * @constructor
  55158. * @param name - The rendering pipeline name
  55159. * @param scene - The scene linked to this pipeline
  55160. * @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 }
  55161. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  55162. */
  55163. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  55164. /**
  55165. * Get the class name
  55166. * @returns "SSAORenderingPipeline"
  55167. */
  55168. getClassName(): string;
  55169. /**
  55170. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  55171. */
  55172. dispose(disableDepthRender?: boolean): void;
  55173. private _createBlurPostProcess;
  55174. /** @hidden */ private _rebuild(): void;
  55175. private _createSSAOPostProcess;
  55176. private _createSSAOCombinePostProcess;
  55177. private _createRandomTexture;
  55178. }
  55179. }
  55180. declare module BABYLON {
  55181. /** @hidden */
  55182. export var standardPixelShader: {
  55183. name: string;
  55184. shader: string;
  55185. };
  55186. }
  55187. declare module BABYLON {
  55188. /**
  55189. * Standard rendering pipeline
  55190. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55191. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  55192. */
  55193. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55194. /**
  55195. * Public members
  55196. */
  55197. /**
  55198. * Post-process which contains the original scene color before the pipeline applies all the effects
  55199. */
  55200. originalPostProcess: Nullable<PostProcess>;
  55201. /**
  55202. * Post-process used to down scale an image x4
  55203. */
  55204. downSampleX4PostProcess: Nullable<PostProcess>;
  55205. /**
  55206. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  55207. */
  55208. brightPassPostProcess: Nullable<PostProcess>;
  55209. /**
  55210. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  55211. */
  55212. blurHPostProcesses: PostProcess[];
  55213. /**
  55214. * Post-process array storing all the vertical blur post-processes used by the pipeline
  55215. */
  55216. blurVPostProcesses: PostProcess[];
  55217. /**
  55218. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  55219. */
  55220. textureAdderPostProcess: Nullable<PostProcess>;
  55221. /**
  55222. * Post-process used to create volumetric lighting effect
  55223. */
  55224. volumetricLightPostProcess: Nullable<PostProcess>;
  55225. /**
  55226. * Post-process used to smooth the previous volumetric light post-process on the X axis
  55227. */
  55228. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  55229. /**
  55230. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  55231. */
  55232. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  55233. /**
  55234. * Post-process used to merge the volumetric light effect and the real scene color
  55235. */
  55236. volumetricLightMergePostProces: Nullable<PostProcess>;
  55237. /**
  55238. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  55239. */
  55240. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  55241. /**
  55242. * Base post-process used to calculate the average luminance of the final image for HDR
  55243. */
  55244. luminancePostProcess: Nullable<PostProcess>;
  55245. /**
  55246. * Post-processes used to create down sample post-processes in order to get
  55247. * the average luminance of the final image for HDR
  55248. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  55249. */
  55250. luminanceDownSamplePostProcesses: PostProcess[];
  55251. /**
  55252. * Post-process used to create a HDR effect (light adaptation)
  55253. */
  55254. hdrPostProcess: Nullable<PostProcess>;
  55255. /**
  55256. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  55257. */
  55258. textureAdderFinalPostProcess: Nullable<PostProcess>;
  55259. /**
  55260. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  55261. */
  55262. lensFlareFinalPostProcess: Nullable<PostProcess>;
  55263. /**
  55264. * Post-process used to merge the final HDR post-process and the real scene color
  55265. */
  55266. hdrFinalPostProcess: Nullable<PostProcess>;
  55267. /**
  55268. * Post-process used to create a lens flare effect
  55269. */
  55270. lensFlarePostProcess: Nullable<PostProcess>;
  55271. /**
  55272. * Post-process that merges the result of the lens flare post-process and the real scene color
  55273. */
  55274. lensFlareComposePostProcess: Nullable<PostProcess>;
  55275. /**
  55276. * Post-process used to create a motion blur effect
  55277. */
  55278. motionBlurPostProcess: Nullable<PostProcess>;
  55279. /**
  55280. * Post-process used to create a depth of field effect
  55281. */
  55282. depthOfFieldPostProcess: Nullable<PostProcess>;
  55283. /**
  55284. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55285. */
  55286. fxaaPostProcess: Nullable<FxaaPostProcess>;
  55287. /**
  55288. * Represents the brightness threshold in order to configure the illuminated surfaces
  55289. */
  55290. brightThreshold: number;
  55291. /**
  55292. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  55293. */
  55294. blurWidth: number;
  55295. /**
  55296. * Sets if the blur for highlighted surfaces must be only horizontal
  55297. */
  55298. horizontalBlur: boolean;
  55299. /**
  55300. * Gets the overall exposure used by the pipeline
  55301. */
  55302. /**
  55303. * Sets the overall exposure used by the pipeline
  55304. */
  55305. exposure: number;
  55306. /**
  55307. * Texture used typically to simulate "dirty" on camera lens
  55308. */
  55309. lensTexture: Nullable<Texture>;
  55310. /**
  55311. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  55312. */
  55313. volumetricLightCoefficient: number;
  55314. /**
  55315. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  55316. */
  55317. volumetricLightPower: number;
  55318. /**
  55319. * Used the set the blur intensity to smooth the volumetric lights
  55320. */
  55321. volumetricLightBlurScale: number;
  55322. /**
  55323. * Light (spot or directional) used to generate the volumetric lights rays
  55324. * The source light must have a shadow generate so the pipeline can get its
  55325. * depth map
  55326. */
  55327. sourceLight: Nullable<SpotLight | DirectionalLight>;
  55328. /**
  55329. * For eye adaptation, represents the minimum luminance the eye can see
  55330. */
  55331. hdrMinimumLuminance: number;
  55332. /**
  55333. * For eye adaptation, represents the decrease luminance speed
  55334. */
  55335. hdrDecreaseRate: number;
  55336. /**
  55337. * For eye adaptation, represents the increase luminance speed
  55338. */
  55339. hdrIncreaseRate: number;
  55340. /**
  55341. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  55342. */
  55343. /**
  55344. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  55345. */
  55346. hdrAutoExposure: boolean;
  55347. /**
  55348. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  55349. */
  55350. lensColorTexture: Nullable<Texture>;
  55351. /**
  55352. * The overall strengh for the lens flare effect
  55353. */
  55354. lensFlareStrength: number;
  55355. /**
  55356. * Dispersion coefficient for lens flare ghosts
  55357. */
  55358. lensFlareGhostDispersal: number;
  55359. /**
  55360. * Main lens flare halo width
  55361. */
  55362. lensFlareHaloWidth: number;
  55363. /**
  55364. * Based on the lens distortion effect, defines how much the lens flare result
  55365. * is distorted
  55366. */
  55367. lensFlareDistortionStrength: number;
  55368. /**
  55369. * Lens star texture must be used to simulate rays on the flares and is available
  55370. * in the documentation
  55371. */
  55372. lensStarTexture: Nullable<Texture>;
  55373. /**
  55374. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  55375. * flare effect by taking account of the dirt texture
  55376. */
  55377. lensFlareDirtTexture: Nullable<Texture>;
  55378. /**
  55379. * Represents the focal length for the depth of field effect
  55380. */
  55381. depthOfFieldDistance: number;
  55382. /**
  55383. * Represents the blur intensity for the blurred part of the depth of field effect
  55384. */
  55385. depthOfFieldBlurWidth: number;
  55386. /**
  55387. * Gets how much the image is blurred by the movement while using the motion blur post-process
  55388. */
  55389. /**
  55390. * Sets how much the image is blurred by the movement while using the motion blur post-process
  55391. */
  55392. motionStrength: number;
  55393. /**
  55394. * Gets wether or not the motion blur post-process is object based or screen based.
  55395. */
  55396. /**
  55397. * Sets wether or not the motion blur post-process should be object based or screen based
  55398. */
  55399. objectBasedMotionBlur: boolean;
  55400. /**
  55401. * List of animations for the pipeline (IAnimatable implementation)
  55402. */
  55403. animations: Animation[];
  55404. /**
  55405. * Private members
  55406. */
  55407. private _scene;
  55408. private _currentDepthOfFieldSource;
  55409. private _basePostProcess;
  55410. private _fixedExposure;
  55411. private _currentExposure;
  55412. private _hdrAutoExposure;
  55413. private _hdrCurrentLuminance;
  55414. private _motionStrength;
  55415. private _isObjectBasedMotionBlur;
  55416. private _floatTextureType;
  55417. private _ratio;
  55418. private _bloomEnabled;
  55419. private _depthOfFieldEnabled;
  55420. private _vlsEnabled;
  55421. private _lensFlareEnabled;
  55422. private _hdrEnabled;
  55423. private _motionBlurEnabled;
  55424. private _fxaaEnabled;
  55425. private _motionBlurSamples;
  55426. private _volumetricLightStepsCount;
  55427. private _samples;
  55428. /**
  55429. * @ignore
  55430. * Specifies if the bloom pipeline is enabled
  55431. */
  55432. BloomEnabled: boolean;
  55433. /**
  55434. * @ignore
  55435. * Specifies if the depth of field pipeline is enabed
  55436. */
  55437. DepthOfFieldEnabled: boolean;
  55438. /**
  55439. * @ignore
  55440. * Specifies if the lens flare pipeline is enabed
  55441. */
  55442. LensFlareEnabled: boolean;
  55443. /**
  55444. * @ignore
  55445. * Specifies if the HDR pipeline is enabled
  55446. */
  55447. HDREnabled: boolean;
  55448. /**
  55449. * @ignore
  55450. * Specifies if the volumetric lights scattering effect is enabled
  55451. */
  55452. VLSEnabled: boolean;
  55453. /**
  55454. * @ignore
  55455. * Specifies if the motion blur effect is enabled
  55456. */
  55457. MotionBlurEnabled: boolean;
  55458. /**
  55459. * Specifies if anti-aliasing is enabled
  55460. */
  55461. fxaaEnabled: boolean;
  55462. /**
  55463. * Specifies the number of steps used to calculate the volumetric lights
  55464. * Typically in interval [50, 200]
  55465. */
  55466. volumetricLightStepsCount: number;
  55467. /**
  55468. * Specifies the number of samples used for the motion blur effect
  55469. * Typically in interval [16, 64]
  55470. */
  55471. motionBlurSamples: number;
  55472. /**
  55473. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55474. */
  55475. samples: number;
  55476. /**
  55477. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  55478. * @constructor
  55479. * @param name The rendering pipeline name
  55480. * @param scene The scene linked to this pipeline
  55481. * @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)
  55482. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  55483. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55484. */
  55485. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  55486. private _buildPipeline;
  55487. private _createDownSampleX4PostProcess;
  55488. private _createBrightPassPostProcess;
  55489. private _createBlurPostProcesses;
  55490. private _createTextureAdderPostProcess;
  55491. private _createVolumetricLightPostProcess;
  55492. private _createLuminancePostProcesses;
  55493. private _createHdrPostProcess;
  55494. private _createLensFlarePostProcess;
  55495. private _createDepthOfFieldPostProcess;
  55496. private _createMotionBlurPostProcess;
  55497. private _getDepthTexture;
  55498. private _disposePostProcesses;
  55499. /**
  55500. * Dispose of the pipeline and stop all post processes
  55501. */
  55502. dispose(): void;
  55503. /**
  55504. * Serialize the rendering pipeline (Used when exporting)
  55505. * @returns the serialized object
  55506. */
  55507. serialize(): any;
  55508. /**
  55509. * Parse the serialized pipeline
  55510. * @param source Source pipeline.
  55511. * @param scene The scene to load the pipeline to.
  55512. * @param rootUrl The URL of the serialized pipeline.
  55513. * @returns An instantiated pipeline from the serialized object.
  55514. */
  55515. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  55516. /**
  55517. * Luminance steps
  55518. */
  55519. static LuminanceSteps: number;
  55520. }
  55521. }
  55522. declare module BABYLON {
  55523. /** @hidden */
  55524. export var tonemapPixelShader: {
  55525. name: string;
  55526. shader: string;
  55527. };
  55528. }
  55529. declare module BABYLON {
  55530. /** Defines operator used for tonemapping */
  55531. export enum TonemappingOperator {
  55532. /** Hable */
  55533. Hable = 0,
  55534. /** Reinhard */
  55535. Reinhard = 1,
  55536. /** HejiDawson */
  55537. HejiDawson = 2,
  55538. /** Photographic */
  55539. Photographic = 3
  55540. }
  55541. /**
  55542. * Defines a post process to apply tone mapping
  55543. */
  55544. export class TonemapPostProcess extends PostProcess {
  55545. private _operator;
  55546. /** Defines the required exposure adjustement */
  55547. exposureAdjustment: number;
  55548. /**
  55549. * Creates a new TonemapPostProcess
  55550. * @param name defines the name of the postprocess
  55551. * @param _operator defines the operator to use
  55552. * @param exposureAdjustment defines the required exposure adjustement
  55553. * @param camera defines the camera to use (can be null)
  55554. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  55555. * @param engine defines the hosting engine (can be ignore if camera is set)
  55556. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  55557. */
  55558. constructor(name: string, _operator: TonemappingOperator,
  55559. /** Defines the required exposure adjustement */
  55560. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  55561. }
  55562. }
  55563. declare module BABYLON {
  55564. /** @hidden */
  55565. export var depthVertexShader: {
  55566. name: string;
  55567. shader: string;
  55568. };
  55569. }
  55570. declare module BABYLON {
  55571. /** @hidden */
  55572. export var volumetricLightScatteringPixelShader: {
  55573. name: string;
  55574. shader: string;
  55575. };
  55576. }
  55577. declare module BABYLON {
  55578. /** @hidden */
  55579. export var volumetricLightScatteringPassPixelShader: {
  55580. name: string;
  55581. shader: string;
  55582. };
  55583. }
  55584. declare module BABYLON {
  55585. /**
  55586. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  55587. */
  55588. export class VolumetricLightScatteringPostProcess extends PostProcess {
  55589. private _volumetricLightScatteringPass;
  55590. private _volumetricLightScatteringRTT;
  55591. private _viewPort;
  55592. private _screenCoordinates;
  55593. private _cachedDefines;
  55594. /**
  55595. * If not undefined, the mesh position is computed from the attached node position
  55596. */
  55597. attachedNode: {
  55598. position: Vector3;
  55599. };
  55600. /**
  55601. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  55602. */
  55603. customMeshPosition: Vector3;
  55604. /**
  55605. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  55606. */
  55607. useCustomMeshPosition: boolean;
  55608. /**
  55609. * If the post-process should inverse the light scattering direction
  55610. */
  55611. invert: boolean;
  55612. /**
  55613. * The internal mesh used by the post-process
  55614. */
  55615. mesh: Mesh;
  55616. /**
  55617. * @hidden
  55618. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  55619. */
  55620. useDiffuseColor: boolean;
  55621. /**
  55622. * Array containing the excluded meshes not rendered in the internal pass
  55623. */
  55624. excludedMeshes: AbstractMesh[];
  55625. /**
  55626. * Controls the overall intensity of the post-process
  55627. */
  55628. exposure: number;
  55629. /**
  55630. * Dissipates each sample's contribution in range [0, 1]
  55631. */
  55632. decay: number;
  55633. /**
  55634. * Controls the overall intensity of each sample
  55635. */
  55636. weight: number;
  55637. /**
  55638. * Controls the density of each sample
  55639. */
  55640. density: number;
  55641. /**
  55642. * @constructor
  55643. * @param name The post-process name
  55644. * @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)
  55645. * @param camera The camera that the post-process will be attached to
  55646. * @param mesh The mesh used to create the light scattering
  55647. * @param samples The post-process quality, default 100
  55648. * @param samplingModeThe post-process filtering mode
  55649. * @param engine The babylon engine
  55650. * @param reusable If the post-process is reusable
  55651. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  55652. */
  55653. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  55654. /**
  55655. * Returns the string "VolumetricLightScatteringPostProcess"
  55656. * @returns "VolumetricLightScatteringPostProcess"
  55657. */
  55658. getClassName(): string;
  55659. private _isReady;
  55660. /**
  55661. * Sets the new light position for light scattering effect
  55662. * @param position The new custom light position
  55663. */
  55664. setCustomMeshPosition(position: Vector3): void;
  55665. /**
  55666. * Returns the light position for light scattering effect
  55667. * @return Vector3 The custom light position
  55668. */
  55669. getCustomMeshPosition(): Vector3;
  55670. /**
  55671. * Disposes the internal assets and detaches the post-process from the camera
  55672. */
  55673. dispose(camera: Camera): void;
  55674. /**
  55675. * Returns the render target texture used by the post-process
  55676. * @return the render target texture used by the post-process
  55677. */
  55678. getPass(): RenderTargetTexture;
  55679. private _meshExcluded;
  55680. private _createPass;
  55681. private _updateMeshScreenCoordinates;
  55682. /**
  55683. * Creates a default mesh for the Volumeric Light Scattering post-process
  55684. * @param name The mesh name
  55685. * @param scene The scene where to create the mesh
  55686. * @return the default mesh
  55687. */
  55688. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  55689. }
  55690. }
  55691. declare module BABYLON {
  55692. interface Scene {
  55693. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  55694. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  55695. /**
  55696. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  55697. */
  55698. forceShowBoundingBoxes: boolean;
  55699. /**
  55700. * Gets the bounding box renderer associated with the scene
  55701. * @returns a BoundingBoxRenderer
  55702. */
  55703. getBoundingBoxRenderer(): BoundingBoxRenderer;
  55704. }
  55705. interface AbstractMesh {
  55706. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  55707. /**
  55708. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  55709. */
  55710. showBoundingBox: boolean;
  55711. }
  55712. /**
  55713. * Component responsible of rendering the bounding box of the meshes in a scene.
  55714. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  55715. */
  55716. export class BoundingBoxRenderer implements ISceneComponent {
  55717. /**
  55718. * The component name helpfull to identify the component in the list of scene components.
  55719. */
  55720. readonly name: string;
  55721. /**
  55722. * The scene the component belongs to.
  55723. */
  55724. scene: Scene;
  55725. /**
  55726. * Color of the bounding box lines placed in front of an object
  55727. */
  55728. frontColor: Color3;
  55729. /**
  55730. * Color of the bounding box lines placed behind an object
  55731. */
  55732. backColor: Color3;
  55733. /**
  55734. * Defines if the renderer should show the back lines or not
  55735. */
  55736. showBackLines: boolean;
  55737. /**
  55738. * @hidden
  55739. */
  55740. renderList: SmartArray<BoundingBox>;
  55741. private _colorShader;
  55742. private _vertexBuffers;
  55743. private _indexBuffer;
  55744. /**
  55745. * Instantiates a new bounding box renderer in a scene.
  55746. * @param scene the scene the renderer renders in
  55747. */
  55748. constructor(scene: Scene);
  55749. /**
  55750. * Registers the component in a given scene
  55751. */
  55752. register(): void;
  55753. private _evaluateSubMesh;
  55754. private _activeMesh;
  55755. private _prepareRessources;
  55756. private _createIndexBuffer;
  55757. /**
  55758. * Rebuilds the elements related to this component in case of
  55759. * context lost for instance.
  55760. */
  55761. rebuild(): void;
  55762. /**
  55763. * @hidden
  55764. */
  55765. reset(): void;
  55766. /**
  55767. * Render the bounding boxes of a specific rendering group
  55768. * @param renderingGroupId defines the rendering group to render
  55769. */
  55770. render(renderingGroupId: number): void;
  55771. /**
  55772. * In case of occlusion queries, we can render the occlusion bounding box through this method
  55773. * @param mesh Define the mesh to render the occlusion bounding box for
  55774. */
  55775. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  55776. /**
  55777. * Dispose and release the resources attached to this renderer.
  55778. */
  55779. dispose(): void;
  55780. }
  55781. }
  55782. declare module BABYLON {
  55783. /** @hidden */
  55784. export var depthPixelShader: {
  55785. name: string;
  55786. shader: string;
  55787. };
  55788. }
  55789. declare module BABYLON {
  55790. /**
  55791. * This represents a depth renderer in Babylon.
  55792. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  55793. */
  55794. export class DepthRenderer {
  55795. private _scene;
  55796. private _depthMap;
  55797. private _effect;
  55798. private _cachedDefines;
  55799. private _camera;
  55800. /**
  55801. * Specifiess that the depth renderer will only be used within
  55802. * the camera it is created for.
  55803. * This can help forcing its rendering during the camera processing.
  55804. */
  55805. useOnlyInActiveCamera: boolean;
  55806. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  55807. /**
  55808. * Instantiates a depth renderer
  55809. * @param scene The scene the renderer belongs to
  55810. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  55811. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  55812. */
  55813. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  55814. /**
  55815. * Creates the depth rendering effect and checks if the effect is ready.
  55816. * @param subMesh The submesh to be used to render the depth map of
  55817. * @param useInstances If multiple world instances should be used
  55818. * @returns if the depth renderer is ready to render the depth map
  55819. */
  55820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55821. /**
  55822. * Gets the texture which the depth map will be written to.
  55823. * @returns The depth map texture
  55824. */
  55825. getDepthMap(): RenderTargetTexture;
  55826. /**
  55827. * Disposes of the depth renderer.
  55828. */
  55829. dispose(): void;
  55830. }
  55831. }
  55832. declare module BABYLON {
  55833. interface Scene {
  55834. /** @hidden (Backing field) */ private _depthRenderer: {
  55835. [id: string]: DepthRenderer;
  55836. };
  55837. /**
  55838. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  55839. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  55840. * @returns the created depth renderer
  55841. */
  55842. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  55843. /**
  55844. * Disables a depth renderer for a given camera
  55845. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  55846. */
  55847. disableDepthRenderer(camera?: Nullable<Camera>): void;
  55848. }
  55849. /**
  55850. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  55851. * in several rendering techniques.
  55852. */
  55853. export class DepthRendererSceneComponent implements ISceneComponent {
  55854. /**
  55855. * The component name helpfull to identify the component in the list of scene components.
  55856. */
  55857. readonly name: string;
  55858. /**
  55859. * The scene the component belongs to.
  55860. */
  55861. scene: Scene;
  55862. /**
  55863. * Creates a new instance of the component for the given scene
  55864. * @param scene Defines the scene to register the component in
  55865. */
  55866. constructor(scene: Scene);
  55867. /**
  55868. * Registers the component in a given scene
  55869. */
  55870. register(): void;
  55871. /**
  55872. * Rebuilds the elements related to this component in case of
  55873. * context lost for instance.
  55874. */
  55875. rebuild(): void;
  55876. /**
  55877. * Disposes the component and the associated ressources
  55878. */
  55879. dispose(): void;
  55880. private _gatherRenderTargets;
  55881. private _gatherActiveCameraRenderTargets;
  55882. }
  55883. }
  55884. declare module BABYLON {
  55885. /** @hidden */
  55886. export var outlinePixelShader: {
  55887. name: string;
  55888. shader: string;
  55889. };
  55890. }
  55891. declare module BABYLON {
  55892. /** @hidden */
  55893. export var outlineVertexShader: {
  55894. name: string;
  55895. shader: string;
  55896. };
  55897. }
  55898. declare module BABYLON {
  55899. interface Scene {
  55900. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  55901. /**
  55902. * Gets the outline renderer associated with the scene
  55903. * @returns a OutlineRenderer
  55904. */
  55905. getOutlineRenderer(): OutlineRenderer;
  55906. }
  55907. interface AbstractMesh {
  55908. /** @hidden (Backing field) */ private _renderOutline: boolean;
  55909. /**
  55910. * Gets or sets a boolean indicating if the outline must be rendered as well
  55911. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  55912. */
  55913. renderOutline: boolean;
  55914. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  55915. /**
  55916. * Gets or sets a boolean indicating if the overlay must be rendered as well
  55917. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  55918. */
  55919. renderOverlay: boolean;
  55920. }
  55921. /**
  55922. * This class is responsible to draw bothe outline/overlay of meshes.
  55923. * It should not be used directly but through the available method on mesh.
  55924. */
  55925. export class OutlineRenderer implements ISceneComponent {
  55926. /**
  55927. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  55928. */
  55929. private static _StencilReference;
  55930. /**
  55931. * The name of the component. Each component must have a unique name.
  55932. */
  55933. name: string;
  55934. /**
  55935. * The scene the component belongs to.
  55936. */
  55937. scene: Scene;
  55938. /**
  55939. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  55940. */
  55941. zOffset: number;
  55942. private _engine;
  55943. private _effect;
  55944. private _cachedDefines;
  55945. private _savedDepthWrite;
  55946. /**
  55947. * Instantiates a new outline renderer. (There could be only one per scene).
  55948. * @param scene Defines the scene it belongs to
  55949. */
  55950. constructor(scene: Scene);
  55951. /**
  55952. * Register the component to one instance of a scene.
  55953. */
  55954. register(): void;
  55955. /**
  55956. * Rebuilds the elements related to this component in case of
  55957. * context lost for instance.
  55958. */
  55959. rebuild(): void;
  55960. /**
  55961. * Disposes the component and the associated ressources.
  55962. */
  55963. dispose(): void;
  55964. /**
  55965. * Renders the outline in the canvas.
  55966. * @param subMesh Defines the sumesh to render
  55967. * @param batch Defines the batch of meshes in case of instances
  55968. * @param useOverlay Defines if the rendering is for the overlay or the outline
  55969. */
  55970. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  55971. /**
  55972. * Returns whether or not the outline renderer is ready for a given submesh.
  55973. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  55974. * @param subMesh Defines the submesh to check readyness for
  55975. * @param useInstances Defines wheter wee are trying to render instances or not
  55976. * @returns true if ready otherwise false
  55977. */
  55978. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55979. private _beforeRenderingMesh;
  55980. private _afterRenderingMesh;
  55981. }
  55982. }
  55983. declare module BABYLON {
  55984. /**
  55985. * Defines the list of states available for a task inside a AssetsManager
  55986. */
  55987. export enum AssetTaskState {
  55988. /**
  55989. * Initialization
  55990. */
  55991. INIT = 0,
  55992. /**
  55993. * Running
  55994. */
  55995. RUNNING = 1,
  55996. /**
  55997. * Done
  55998. */
  55999. DONE = 2,
  56000. /**
  56001. * Error
  56002. */
  56003. ERROR = 3
  56004. }
  56005. /**
  56006. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  56007. */
  56008. export abstract class AbstractAssetTask {
  56009. /**
  56010. * Task name
  56011. */ name: string;
  56012. /**
  56013. * Callback called when the task is successful
  56014. */
  56015. onSuccess: (task: any) => void;
  56016. /**
  56017. * Callback called when the task is not successful
  56018. */
  56019. onError: (task: any, message?: string, exception?: any) => void;
  56020. /**
  56021. * Creates a new AssetsManager
  56022. * @param name defines the name of the task
  56023. */
  56024. constructor(
  56025. /**
  56026. * Task name
  56027. */ name: string);
  56028. private _isCompleted;
  56029. private _taskState;
  56030. private _errorObject;
  56031. /**
  56032. * Get if the task is completed
  56033. */
  56034. readonly isCompleted: boolean;
  56035. /**
  56036. * Gets the current state of the task
  56037. */
  56038. readonly taskState: AssetTaskState;
  56039. /**
  56040. * Gets the current error object (if task is in error)
  56041. */
  56042. readonly errorObject: {
  56043. message?: string;
  56044. exception?: any;
  56045. };
  56046. /**
  56047. * Internal only
  56048. * @hidden
  56049. */ private _setErrorObject(message?: string, exception?: any): void;
  56050. /**
  56051. * Execute the current task
  56052. * @param scene defines the scene where you want your assets to be loaded
  56053. * @param onSuccess is a callback called when the task is successfully executed
  56054. * @param onError is a callback called if an error occurs
  56055. */
  56056. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56057. /**
  56058. * Execute the current task
  56059. * @param scene defines the scene where you want your assets to be loaded
  56060. * @param onSuccess is a callback called when the task is successfully executed
  56061. * @param onError is a callback called if an error occurs
  56062. */
  56063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56064. /**
  56065. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  56066. * This can be used with failed tasks that have the reason for failure fixed.
  56067. */
  56068. reset(): void;
  56069. private onErrorCallback;
  56070. private onDoneCallback;
  56071. }
  56072. /**
  56073. * Define the interface used by progress events raised during assets loading
  56074. */
  56075. export interface IAssetsProgressEvent {
  56076. /**
  56077. * Defines the number of remaining tasks to process
  56078. */
  56079. remainingCount: number;
  56080. /**
  56081. * Defines the total number of tasks
  56082. */
  56083. totalCount: number;
  56084. /**
  56085. * Defines the task that was just processed
  56086. */
  56087. task: AbstractAssetTask;
  56088. }
  56089. /**
  56090. * Class used to share progress information about assets loading
  56091. */
  56092. export class AssetsProgressEvent implements IAssetsProgressEvent {
  56093. /**
  56094. * Defines the number of remaining tasks to process
  56095. */
  56096. remainingCount: number;
  56097. /**
  56098. * Defines the total number of tasks
  56099. */
  56100. totalCount: number;
  56101. /**
  56102. * Defines the task that was just processed
  56103. */
  56104. task: AbstractAssetTask;
  56105. /**
  56106. * Creates a AssetsProgressEvent
  56107. * @param remainingCount defines the number of remaining tasks to process
  56108. * @param totalCount defines the total number of tasks
  56109. * @param task defines the task that was just processed
  56110. */
  56111. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  56112. }
  56113. /**
  56114. * Define a task used by AssetsManager to load meshes
  56115. */
  56116. export class MeshAssetTask extends AbstractAssetTask {
  56117. /**
  56118. * Defines the name of the task
  56119. */
  56120. name: string;
  56121. /**
  56122. * Defines the list of mesh's names you want to load
  56123. */
  56124. meshesNames: any;
  56125. /**
  56126. * Defines the root url to use as a base to load your meshes and associated resources
  56127. */
  56128. rootUrl: string;
  56129. /**
  56130. * Defines the filename of the scene to load from
  56131. */
  56132. sceneFilename: string;
  56133. /**
  56134. * Gets the list of loaded meshes
  56135. */
  56136. loadedMeshes: Array<AbstractMesh>;
  56137. /**
  56138. * Gets the list of loaded particle systems
  56139. */
  56140. loadedParticleSystems: Array<IParticleSystem>;
  56141. /**
  56142. * Gets the list of loaded skeletons
  56143. */
  56144. loadedSkeletons: Array<Skeleton>;
  56145. /**
  56146. * Gets the list of loaded animation groups
  56147. */
  56148. loadedAnimationGroups: Array<AnimationGroup>;
  56149. /**
  56150. * Callback called when the task is successful
  56151. */
  56152. onSuccess: (task: MeshAssetTask) => void;
  56153. /**
  56154. * Callback called when the task is successful
  56155. */
  56156. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  56157. /**
  56158. * Creates a new MeshAssetTask
  56159. * @param name defines the name of the task
  56160. * @param meshesNames defines the list of mesh's names you want to load
  56161. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  56162. * @param sceneFilename defines the filename of the scene to load from
  56163. */
  56164. constructor(
  56165. /**
  56166. * Defines the name of the task
  56167. */
  56168. name: string,
  56169. /**
  56170. * Defines the list of mesh's names you want to load
  56171. */
  56172. meshesNames: any,
  56173. /**
  56174. * Defines the root url to use as a base to load your meshes and associated resources
  56175. */
  56176. rootUrl: string,
  56177. /**
  56178. * Defines the filename of the scene to load from
  56179. */
  56180. sceneFilename: string);
  56181. /**
  56182. * Execute the current task
  56183. * @param scene defines the scene where you want your assets to be loaded
  56184. * @param onSuccess is a callback called when the task is successfully executed
  56185. * @param onError is a callback called if an error occurs
  56186. */
  56187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56188. }
  56189. /**
  56190. * Define a task used by AssetsManager to load text content
  56191. */
  56192. export class TextFileAssetTask extends AbstractAssetTask {
  56193. /**
  56194. * Defines the name of the task
  56195. */
  56196. name: string;
  56197. /**
  56198. * Defines the location of the file to load
  56199. */
  56200. url: string;
  56201. /**
  56202. * Gets the loaded text string
  56203. */
  56204. text: string;
  56205. /**
  56206. * Callback called when the task is successful
  56207. */
  56208. onSuccess: (task: TextFileAssetTask) => void;
  56209. /**
  56210. * Callback called when the task is successful
  56211. */
  56212. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  56213. /**
  56214. * Creates a new TextFileAssetTask object
  56215. * @param name defines the name of the task
  56216. * @param url defines the location of the file to load
  56217. */
  56218. constructor(
  56219. /**
  56220. * Defines the name of the task
  56221. */
  56222. name: string,
  56223. /**
  56224. * Defines the location of the file to load
  56225. */
  56226. url: string);
  56227. /**
  56228. * Execute the current task
  56229. * @param scene defines the scene where you want your assets to be loaded
  56230. * @param onSuccess is a callback called when the task is successfully executed
  56231. * @param onError is a callback called if an error occurs
  56232. */
  56233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56234. }
  56235. /**
  56236. * Define a task used by AssetsManager to load binary data
  56237. */
  56238. export class BinaryFileAssetTask extends AbstractAssetTask {
  56239. /**
  56240. * Defines the name of the task
  56241. */
  56242. name: string;
  56243. /**
  56244. * Defines the location of the file to load
  56245. */
  56246. url: string;
  56247. /**
  56248. * Gets the lodaded data (as an array buffer)
  56249. */
  56250. data: ArrayBuffer;
  56251. /**
  56252. * Callback called when the task is successful
  56253. */
  56254. onSuccess: (task: BinaryFileAssetTask) => void;
  56255. /**
  56256. * Callback called when the task is successful
  56257. */
  56258. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  56259. /**
  56260. * Creates a new BinaryFileAssetTask object
  56261. * @param name defines the name of the new task
  56262. * @param url defines the location of the file to load
  56263. */
  56264. constructor(
  56265. /**
  56266. * Defines the name of the task
  56267. */
  56268. name: string,
  56269. /**
  56270. * Defines the location of the file to load
  56271. */
  56272. url: string);
  56273. /**
  56274. * Execute the current task
  56275. * @param scene defines the scene where you want your assets to be loaded
  56276. * @param onSuccess is a callback called when the task is successfully executed
  56277. * @param onError is a callback called if an error occurs
  56278. */
  56279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56280. }
  56281. /**
  56282. * Define a task used by AssetsManager to load images
  56283. */
  56284. export class ImageAssetTask extends AbstractAssetTask {
  56285. /**
  56286. * Defines the name of the task
  56287. */
  56288. name: string;
  56289. /**
  56290. * Defines the location of the image to load
  56291. */
  56292. url: string;
  56293. /**
  56294. * Gets the loaded images
  56295. */
  56296. image: HTMLImageElement;
  56297. /**
  56298. * Callback called when the task is successful
  56299. */
  56300. onSuccess: (task: ImageAssetTask) => void;
  56301. /**
  56302. * Callback called when the task is successful
  56303. */
  56304. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  56305. /**
  56306. * Creates a new ImageAssetTask
  56307. * @param name defines the name of the task
  56308. * @param url defines the location of the image to load
  56309. */
  56310. constructor(
  56311. /**
  56312. * Defines the name of the task
  56313. */
  56314. name: string,
  56315. /**
  56316. * Defines the location of the image to load
  56317. */
  56318. url: string);
  56319. /**
  56320. * Execute the current task
  56321. * @param scene defines the scene where you want your assets to be loaded
  56322. * @param onSuccess is a callback called when the task is successfully executed
  56323. * @param onError is a callback called if an error occurs
  56324. */
  56325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56326. }
  56327. /**
  56328. * Defines the interface used by texture loading tasks
  56329. */
  56330. export interface ITextureAssetTask<TEX extends BaseTexture> {
  56331. /**
  56332. * Gets the loaded texture
  56333. */
  56334. texture: TEX;
  56335. }
  56336. /**
  56337. * Define a task used by AssetsManager to load 2D textures
  56338. */
  56339. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  56340. /**
  56341. * Defines the name of the task
  56342. */
  56343. name: string;
  56344. /**
  56345. * Defines the location of the file to load
  56346. */
  56347. url: string;
  56348. /**
  56349. * Defines if mipmap should not be generated (default is false)
  56350. */
  56351. noMipmap?: boolean | undefined;
  56352. /**
  56353. * Defines if texture must be inverted on Y axis (default is false)
  56354. */
  56355. invertY?: boolean | undefined;
  56356. /**
  56357. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56358. */
  56359. samplingMode: number;
  56360. /**
  56361. * Gets the loaded texture
  56362. */
  56363. texture: Texture;
  56364. /**
  56365. * Callback called when the task is successful
  56366. */
  56367. onSuccess: (task: TextureAssetTask) => void;
  56368. /**
  56369. * Callback called when the task is successful
  56370. */
  56371. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  56372. /**
  56373. * Creates a new TextureAssetTask object
  56374. * @param name defines the name of the task
  56375. * @param url defines the location of the file to load
  56376. * @param noMipmap defines if mipmap should not be generated (default is false)
  56377. * @param invertY defines if texture must be inverted on Y axis (default is false)
  56378. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56379. */
  56380. constructor(
  56381. /**
  56382. * Defines the name of the task
  56383. */
  56384. name: string,
  56385. /**
  56386. * Defines the location of the file to load
  56387. */
  56388. url: string,
  56389. /**
  56390. * Defines if mipmap should not be generated (default is false)
  56391. */
  56392. noMipmap?: boolean | undefined,
  56393. /**
  56394. * Defines if texture must be inverted on Y axis (default is false)
  56395. */
  56396. invertY?: boolean | undefined,
  56397. /**
  56398. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56399. */
  56400. samplingMode?: number);
  56401. /**
  56402. * Execute the current task
  56403. * @param scene defines the scene where you want your assets to be loaded
  56404. * @param onSuccess is a callback called when the task is successfully executed
  56405. * @param onError is a callback called if an error occurs
  56406. */
  56407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56408. }
  56409. /**
  56410. * Define a task used by AssetsManager to load cube textures
  56411. */
  56412. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  56413. /**
  56414. * Defines the name of the task
  56415. */
  56416. name: string;
  56417. /**
  56418. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56419. */
  56420. url: string;
  56421. /**
  56422. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56423. */
  56424. extensions?: string[] | undefined;
  56425. /**
  56426. * Defines if mipmaps should not be generated (default is false)
  56427. */
  56428. noMipmap?: boolean | undefined;
  56429. /**
  56430. * Defines the explicit list of files (undefined by default)
  56431. */
  56432. files?: string[] | undefined;
  56433. /**
  56434. * Gets the loaded texture
  56435. */
  56436. texture: CubeTexture;
  56437. /**
  56438. * Callback called when the task is successful
  56439. */
  56440. onSuccess: (task: CubeTextureAssetTask) => void;
  56441. /**
  56442. * Callback called when the task is successful
  56443. */
  56444. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  56445. /**
  56446. * Creates a new CubeTextureAssetTask
  56447. * @param name defines the name of the task
  56448. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56449. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56450. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56451. * @param files defines the explicit list of files (undefined by default)
  56452. */
  56453. constructor(
  56454. /**
  56455. * Defines the name of the task
  56456. */
  56457. name: string,
  56458. /**
  56459. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  56460. */
  56461. url: string,
  56462. /**
  56463. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  56464. */
  56465. extensions?: string[] | undefined,
  56466. /**
  56467. * Defines if mipmaps should not be generated (default is false)
  56468. */
  56469. noMipmap?: boolean | undefined,
  56470. /**
  56471. * Defines the explicit list of files (undefined by default)
  56472. */
  56473. files?: string[] | undefined);
  56474. /**
  56475. * Execute the current task
  56476. * @param scene defines the scene where you want your assets to be loaded
  56477. * @param onSuccess is a callback called when the task is successfully executed
  56478. * @param onError is a callback called if an error occurs
  56479. */
  56480. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56481. }
  56482. /**
  56483. * Define a task used by AssetsManager to load HDR cube textures
  56484. */
  56485. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  56486. /**
  56487. * Defines the name of the task
  56488. */
  56489. name: string;
  56490. /**
  56491. * Defines the location of the file to load
  56492. */
  56493. url: string;
  56494. /**
  56495. * Defines the desired size (the more it increases the longer the generation will be)
  56496. */
  56497. size: number;
  56498. /**
  56499. * Defines if mipmaps should not be generated (default is false)
  56500. */
  56501. noMipmap: boolean;
  56502. /**
  56503. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56504. */
  56505. generateHarmonics: boolean;
  56506. /**
  56507. * 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)
  56508. */
  56509. gammaSpace: boolean;
  56510. /**
  56511. * Internal Use Only
  56512. */
  56513. reserved: boolean;
  56514. /**
  56515. * Gets the loaded texture
  56516. */
  56517. texture: HDRCubeTexture;
  56518. /**
  56519. * Callback called when the task is successful
  56520. */
  56521. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  56522. /**
  56523. * Callback called when the task is successful
  56524. */
  56525. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  56526. /**
  56527. * Creates a new HDRCubeTextureAssetTask object
  56528. * @param name defines the name of the task
  56529. * @param url defines the location of the file to load
  56530. * @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.
  56531. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56532. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56533. * @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)
  56534. * @param reserved Internal use only
  56535. */
  56536. constructor(
  56537. /**
  56538. * Defines the name of the task
  56539. */
  56540. name: string,
  56541. /**
  56542. * Defines the location of the file to load
  56543. */
  56544. url: string,
  56545. /**
  56546. * Defines the desired size (the more it increases the longer the generation will be)
  56547. */
  56548. size: number,
  56549. /**
  56550. * Defines if mipmaps should not be generated (default is false)
  56551. */
  56552. noMipmap?: boolean,
  56553. /**
  56554. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  56555. */
  56556. generateHarmonics?: boolean,
  56557. /**
  56558. * 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)
  56559. */
  56560. gammaSpace?: boolean,
  56561. /**
  56562. * Internal Use Only
  56563. */
  56564. reserved?: boolean);
  56565. /**
  56566. * Execute the current task
  56567. * @param scene defines the scene where you want your assets to be loaded
  56568. * @param onSuccess is a callback called when the task is successfully executed
  56569. * @param onError is a callback called if an error occurs
  56570. */
  56571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56572. }
  56573. /**
  56574. * Define a task used by AssetsManager to load Equirectangular cube textures
  56575. */
  56576. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  56577. /**
  56578. * Defines the name of the task
  56579. */
  56580. name: string;
  56581. /**
  56582. * Defines the location of the file to load
  56583. */
  56584. url: string;
  56585. /**
  56586. * Defines the desired size (the more it increases the longer the generation will be)
  56587. */
  56588. size: number;
  56589. /**
  56590. * Defines if mipmaps should not be generated (default is false)
  56591. */
  56592. noMipmap: boolean;
  56593. /**
  56594. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  56595. * but the standard material would require them in Gamma space) (default is true)
  56596. */
  56597. gammaSpace: boolean;
  56598. /**
  56599. * Gets the loaded texture
  56600. */
  56601. texture: EquiRectangularCubeTexture;
  56602. /**
  56603. * Callback called when the task is successful
  56604. */
  56605. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  56606. /**
  56607. * Callback called when the task is successful
  56608. */
  56609. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  56610. /**
  56611. * Creates a new EquiRectangularCubeTextureAssetTask object
  56612. * @param name defines the name of the task
  56613. * @param url defines the location of the file to load
  56614. * @param size defines the desired size (the more it increases the longer the generation will be)
  56615. * If the size is omitted this implies you are using a preprocessed cubemap.
  56616. * @param noMipmap defines if mipmaps should not be generated (default is false)
  56617. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  56618. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  56619. * (default is true)
  56620. */
  56621. constructor(
  56622. /**
  56623. * Defines the name of the task
  56624. */
  56625. name: string,
  56626. /**
  56627. * Defines the location of the file to load
  56628. */
  56629. url: string,
  56630. /**
  56631. * Defines the desired size (the more it increases the longer the generation will be)
  56632. */
  56633. size: number,
  56634. /**
  56635. * Defines if mipmaps should not be generated (default is false)
  56636. */
  56637. noMipmap?: boolean,
  56638. /**
  56639. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  56640. * but the standard material would require them in Gamma space) (default is true)
  56641. */
  56642. gammaSpace?: boolean);
  56643. /**
  56644. * Execute the current task
  56645. * @param scene defines the scene where you want your assets to be loaded
  56646. * @param onSuccess is a callback called when the task is successfully executed
  56647. * @param onError is a callback called if an error occurs
  56648. */
  56649. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  56650. }
  56651. /**
  56652. * This class can be used to easily import assets into a scene
  56653. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  56654. */
  56655. export class AssetsManager {
  56656. private _scene;
  56657. private _isLoading;
  56658. protected _tasks: AbstractAssetTask[];
  56659. protected _waitingTasksCount: number;
  56660. protected _totalTasksCount: number;
  56661. /**
  56662. * Callback called when all tasks are processed
  56663. */
  56664. onFinish: (tasks: AbstractAssetTask[]) => void;
  56665. /**
  56666. * Callback called when a task is successful
  56667. */
  56668. onTaskSuccess: (task: AbstractAssetTask) => void;
  56669. /**
  56670. * Callback called when a task had an error
  56671. */
  56672. onTaskError: (task: AbstractAssetTask) => void;
  56673. /**
  56674. * Callback called when a task is done (whatever the result is)
  56675. */
  56676. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  56677. /**
  56678. * Observable called when all tasks are processed
  56679. */
  56680. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  56681. /**
  56682. * Observable called when a task had an error
  56683. */
  56684. onTaskErrorObservable: Observable<AbstractAssetTask>;
  56685. /**
  56686. * Observable called when all tasks were executed
  56687. */
  56688. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  56689. /**
  56690. * Observable called when a task is done (whatever the result is)
  56691. */
  56692. onProgressObservable: Observable<IAssetsProgressEvent>;
  56693. /**
  56694. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  56695. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  56696. */
  56697. useDefaultLoadingScreen: boolean;
  56698. /**
  56699. * Creates a new AssetsManager
  56700. * @param scene defines the scene to work on
  56701. */
  56702. constructor(scene: Scene);
  56703. /**
  56704. * Add a MeshAssetTask to the list of active tasks
  56705. * @param taskName defines the name of the new task
  56706. * @param meshesNames defines the name of meshes to load
  56707. * @param rootUrl defines the root url to use to locate files
  56708. * @param sceneFilename defines the filename of the scene file
  56709. * @returns a new MeshAssetTask object
  56710. */
  56711. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  56712. /**
  56713. * Add a TextFileAssetTask to the list of active tasks
  56714. * @param taskName defines the name of the new task
  56715. * @param url defines the url of the file to load
  56716. * @returns a new TextFileAssetTask object
  56717. */
  56718. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  56719. /**
  56720. * Add a BinaryFileAssetTask to the list of active tasks
  56721. * @param taskName defines the name of the new task
  56722. * @param url defines the url of the file to load
  56723. * @returns a new BinaryFileAssetTask object
  56724. */
  56725. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  56726. /**
  56727. * Add a ImageAssetTask to the list of active tasks
  56728. * @param taskName defines the name of the new task
  56729. * @param url defines the url of the file to load
  56730. * @returns a new ImageAssetTask object
  56731. */
  56732. addImageTask(taskName: string, url: string): ImageAssetTask;
  56733. /**
  56734. * Add a TextureAssetTask to the list of active tasks
  56735. * @param taskName defines the name of the new task
  56736. * @param url defines the url of the file to load
  56737. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56738. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  56739. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  56740. * @returns a new TextureAssetTask object
  56741. */
  56742. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  56743. /**
  56744. * Add a CubeTextureAssetTask to the list of active tasks
  56745. * @param taskName defines the name of the new task
  56746. * @param url defines the url of the file to load
  56747. * @param extensions defines the extension to use to load the cube map (can be null)
  56748. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56749. * @param files defines the list of files to load (can be null)
  56750. * @returns a new CubeTextureAssetTask object
  56751. */
  56752. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  56753. /**
  56754. *
  56755. * Add a HDRCubeTextureAssetTask to the list of active tasks
  56756. * @param taskName defines the name of the new task
  56757. * @param url defines the url of the file to load
  56758. * @param size defines the size you want for the cubemap (can be null)
  56759. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56760. * @param generateHarmonics defines if you want to automatically generate (true by default)
  56761. * @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)
  56762. * @param reserved Internal use only
  56763. * @returns a new HDRCubeTextureAssetTask object
  56764. */
  56765. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  56766. /**
  56767. *
  56768. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  56769. * @param taskName defines the name of the new task
  56770. * @param url defines the url of the file to load
  56771. * @param size defines the size you want for the cubemap (can be null)
  56772. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  56773. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  56774. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  56775. * @returns a new EquiRectangularCubeTextureAssetTask object
  56776. */
  56777. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  56778. /**
  56779. * Remove a task from the assets manager.
  56780. * @param task the task to remove
  56781. */
  56782. removeTask(task: AbstractAssetTask): void;
  56783. private _decreaseWaitingTasksCount;
  56784. private _runTask;
  56785. /**
  56786. * Reset the AssetsManager and remove all tasks
  56787. * @return the current instance of the AssetsManager
  56788. */
  56789. reset(): AssetsManager;
  56790. /**
  56791. * Start the loading process
  56792. * @return the current instance of the AssetsManager
  56793. */
  56794. load(): AssetsManager;
  56795. /**
  56796. * Start the loading process as an async operation
  56797. * @return a promise returning the list of failed tasks
  56798. */
  56799. loadAsync(): Promise<void>;
  56800. }
  56801. }
  56802. declare module BABYLON {
  56803. /**
  56804. * Wrapper class for promise with external resolve and reject.
  56805. */
  56806. export class Deferred<T> {
  56807. /**
  56808. * The promise associated with this deferred object.
  56809. */
  56810. readonly promise: Promise<T>;
  56811. private _resolve;
  56812. private _reject;
  56813. /**
  56814. * The resolve method of the promise associated with this deferred object.
  56815. */
  56816. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  56817. /**
  56818. * The reject method of the promise associated with this deferred object.
  56819. */
  56820. readonly reject: (reason?: any) => void;
  56821. /**
  56822. * Constructor for this deferred object.
  56823. */
  56824. constructor();
  56825. }
  56826. }
  56827. declare module BABYLON {
  56828. /**
  56829. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  56830. */
  56831. export class MeshExploder {
  56832. private _centerMesh;
  56833. private _meshes;
  56834. private _meshesOrigins;
  56835. private _toCenterVectors;
  56836. private _scaledDirection;
  56837. private _newPosition;
  56838. private _centerPosition;
  56839. /**
  56840. * Explodes meshes from a center mesh.
  56841. * @param meshes The meshes to explode.
  56842. * @param centerMesh The mesh to be center of explosion.
  56843. */
  56844. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  56845. private _setCenterMesh;
  56846. /**
  56847. * Get class name
  56848. * @returns "MeshExploder"
  56849. */
  56850. getClassName(): string;
  56851. /**
  56852. * "Exploded meshes"
  56853. * @returns Array of meshes with the centerMesh at index 0.
  56854. */
  56855. getMeshes(): Array<Mesh>;
  56856. /**
  56857. * Explodes meshes giving a specific direction
  56858. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  56859. */
  56860. explode(direction?: number): void;
  56861. }
  56862. }
  56863. declare module BABYLON {
  56864. /**
  56865. * Class used to help managing file picking and drag'n'drop
  56866. */
  56867. export class FilesInput {
  56868. /**
  56869. * List of files ready to be loaded
  56870. */
  56871. static readonly FilesToLoad: {
  56872. [key: string]: File;
  56873. };
  56874. /**
  56875. * Callback called when a file is processed
  56876. */
  56877. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  56878. private _engine;
  56879. private _currentScene;
  56880. private _sceneLoadedCallback;
  56881. private _progressCallback;
  56882. private _additionalRenderLoopLogicCallback;
  56883. private _textureLoadingCallback;
  56884. private _startingProcessingFilesCallback;
  56885. private _onReloadCallback;
  56886. private _errorCallback;
  56887. private _elementToMonitor;
  56888. private _sceneFileToLoad;
  56889. private _filesToLoad;
  56890. /**
  56891. * Creates a new FilesInput
  56892. * @param engine defines the rendering engine
  56893. * @param scene defines the hosting scene
  56894. * @param sceneLoadedCallback callback called when scene is loaded
  56895. * @param progressCallback callback called to track progress
  56896. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  56897. * @param textureLoadingCallback callback called when a texture is loading
  56898. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  56899. * @param onReloadCallback callback called when a reload is requested
  56900. * @param errorCallback callback call if an error occurs
  56901. */
  56902. 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);
  56903. private _dragEnterHandler;
  56904. private _dragOverHandler;
  56905. private _dropHandler;
  56906. /**
  56907. * Calls this function to listen to drag'n'drop events on a specific DOM element
  56908. * @param elementToMonitor defines the DOM element to track
  56909. */
  56910. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  56911. /**
  56912. * Release all associated resources
  56913. */
  56914. dispose(): void;
  56915. private renderFunction;
  56916. private drag;
  56917. private drop;
  56918. private _traverseFolder;
  56919. private _processFiles;
  56920. /**
  56921. * Load files from a drop event
  56922. * @param event defines the drop event to use as source
  56923. */
  56924. loadFiles(event: any): void;
  56925. private _processReload;
  56926. /**
  56927. * Reload the current scene from the loaded files
  56928. */
  56929. reload(): void;
  56930. }
  56931. }
  56932. declare module BABYLON {
  56933. /**
  56934. * Defines the root class used to create scene optimization to use with SceneOptimizer
  56935. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56936. */
  56937. export class SceneOptimization {
  56938. /**
  56939. * Defines the priority of this optimization (0 by default which means first in the list)
  56940. */
  56941. priority: number;
  56942. /**
  56943. * Gets a string describing the action executed by the current optimization
  56944. * @returns description string
  56945. */
  56946. getDescription(): string;
  56947. /**
  56948. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  56949. * @param scene defines the current scene where to apply this optimization
  56950. * @param optimizer defines the current optimizer
  56951. * @returns true if everything that can be done was applied
  56952. */
  56953. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  56954. /**
  56955. * Creates the SceneOptimization object
  56956. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56957. * @param desc defines the description associated with the optimization
  56958. */
  56959. constructor(
  56960. /**
  56961. * Defines the priority of this optimization (0 by default which means first in the list)
  56962. */
  56963. priority?: number);
  56964. }
  56965. /**
  56966. * Defines an optimization used to reduce the size of render target textures
  56967. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  56968. */
  56969. export class TextureOptimization extends SceneOptimization {
  56970. /**
  56971. * Defines the priority of this optimization (0 by default which means first in the list)
  56972. */
  56973. priority: number;
  56974. /**
  56975. * 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
  56976. */
  56977. maximumSize: number;
  56978. /**
  56979. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56980. */
  56981. step: number;
  56982. /**
  56983. * Gets a string describing the action executed by the current optimization
  56984. * @returns description string
  56985. */
  56986. getDescription(): string;
  56987. /**
  56988. * Creates the TextureOptimization object
  56989. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  56990. * @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
  56991. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  56992. */
  56993. constructor(
  56994. /**
  56995. * Defines the priority of this optimization (0 by default which means first in the list)
  56996. */
  56997. priority?: number,
  56998. /**
  56999. * 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
  57000. */
  57001. maximumSize?: number,
  57002. /**
  57003. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  57004. */
  57005. step?: number);
  57006. /**
  57007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57008. * @param scene defines the current scene where to apply this optimization
  57009. * @param optimizer defines the current optimizer
  57010. * @returns true if everything that can be done was applied
  57011. */
  57012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57013. }
  57014. /**
  57015. * Defines an optimization used to increase or decrease the rendering resolution
  57016. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57017. */
  57018. export class HardwareScalingOptimization extends SceneOptimization {
  57019. /**
  57020. * Defines the priority of this optimization (0 by default which means first in the list)
  57021. */
  57022. priority: number;
  57023. /**
  57024. * Defines the maximum scale to use (2 by default)
  57025. */
  57026. maximumScale: number;
  57027. /**
  57028. * Defines the step to use between two passes (0.5 by default)
  57029. */
  57030. step: number;
  57031. private _currentScale;
  57032. private _directionOffset;
  57033. /**
  57034. * Gets a string describing the action executed by the current optimization
  57035. * @return description string
  57036. */
  57037. getDescription(): string;
  57038. /**
  57039. * Creates the HardwareScalingOptimization object
  57040. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57041. * @param maximumScale defines the maximum scale to use (2 by default)
  57042. * @param step defines the step to use between two passes (0.5 by default)
  57043. */
  57044. constructor(
  57045. /**
  57046. * Defines the priority of this optimization (0 by default which means first in the list)
  57047. */
  57048. priority?: number,
  57049. /**
  57050. * Defines the maximum scale to use (2 by default)
  57051. */
  57052. maximumScale?: number,
  57053. /**
  57054. * Defines the step to use between two passes (0.5 by default)
  57055. */
  57056. step?: number);
  57057. /**
  57058. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57059. * @param scene defines the current scene where to apply this optimization
  57060. * @param optimizer defines the current optimizer
  57061. * @returns true if everything that can be done was applied
  57062. */
  57063. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57064. }
  57065. /**
  57066. * Defines an optimization used to remove shadows
  57067. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57068. */
  57069. export class ShadowsOptimization extends SceneOptimization {
  57070. /**
  57071. * Gets a string describing the action executed by the current optimization
  57072. * @return description string
  57073. */
  57074. getDescription(): string;
  57075. /**
  57076. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57077. * @param scene defines the current scene where to apply this optimization
  57078. * @param optimizer defines the current optimizer
  57079. * @returns true if everything that can be done was applied
  57080. */
  57081. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57082. }
  57083. /**
  57084. * Defines an optimization used to turn post-processes off
  57085. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57086. */
  57087. export class PostProcessesOptimization extends SceneOptimization {
  57088. /**
  57089. * Gets a string describing the action executed by the current optimization
  57090. * @return description string
  57091. */
  57092. getDescription(): string;
  57093. /**
  57094. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57095. * @param scene defines the current scene where to apply this optimization
  57096. * @param optimizer defines the current optimizer
  57097. * @returns true if everything that can be done was applied
  57098. */
  57099. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57100. }
  57101. /**
  57102. * Defines an optimization used to turn lens flares off
  57103. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57104. */
  57105. export class LensFlaresOptimization extends SceneOptimization {
  57106. /**
  57107. * Gets a string describing the action executed by the current optimization
  57108. * @return description string
  57109. */
  57110. getDescription(): string;
  57111. /**
  57112. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57113. * @param scene defines the current scene where to apply this optimization
  57114. * @param optimizer defines the current optimizer
  57115. * @returns true if everything that can be done was applied
  57116. */
  57117. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57118. }
  57119. /**
  57120. * Defines an optimization based on user defined callback.
  57121. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57122. */
  57123. export class CustomOptimization extends SceneOptimization {
  57124. /**
  57125. * Callback called to apply the custom optimization.
  57126. */
  57127. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  57128. /**
  57129. * Callback called to get custom description
  57130. */
  57131. onGetDescription: () => string;
  57132. /**
  57133. * Gets a string describing the action executed by the current optimization
  57134. * @returns description string
  57135. */
  57136. getDescription(): string;
  57137. /**
  57138. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57139. * @param scene defines the current scene where to apply this optimization
  57140. * @param optimizer defines the current optimizer
  57141. * @returns true if everything that can be done was applied
  57142. */
  57143. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57144. }
  57145. /**
  57146. * Defines an optimization used to turn particles off
  57147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57148. */
  57149. export class ParticlesOptimization extends SceneOptimization {
  57150. /**
  57151. * Gets a string describing the action executed by the current optimization
  57152. * @return description string
  57153. */
  57154. getDescription(): string;
  57155. /**
  57156. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57157. * @param scene defines the current scene where to apply this optimization
  57158. * @param optimizer defines the current optimizer
  57159. * @returns true if everything that can be done was applied
  57160. */
  57161. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57162. }
  57163. /**
  57164. * Defines an optimization used to turn render targets off
  57165. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57166. */
  57167. export class RenderTargetsOptimization extends SceneOptimization {
  57168. /**
  57169. * Gets a string describing the action executed by the current optimization
  57170. * @return description string
  57171. */
  57172. getDescription(): string;
  57173. /**
  57174. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57175. * @param scene defines the current scene where to apply this optimization
  57176. * @param optimizer defines the current optimizer
  57177. * @returns true if everything that can be done was applied
  57178. */
  57179. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  57180. }
  57181. /**
  57182. * Defines an optimization used to merge meshes with compatible materials
  57183. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57184. */
  57185. export class MergeMeshesOptimization extends SceneOptimization {
  57186. private static _UpdateSelectionTree;
  57187. /**
  57188. * Gets or sets a boolean which defines if optimization octree has to be updated
  57189. */
  57190. /**
  57191. * Gets or sets a boolean which defines if optimization octree has to be updated
  57192. */
  57193. static UpdateSelectionTree: boolean;
  57194. /**
  57195. * Gets a string describing the action executed by the current optimization
  57196. * @return description string
  57197. */
  57198. getDescription(): string;
  57199. private _canBeMerged;
  57200. /**
  57201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  57202. * @param scene defines the current scene where to apply this optimization
  57203. * @param optimizer defines the current optimizer
  57204. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  57205. * @returns true if everything that can be done was applied
  57206. */
  57207. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  57208. }
  57209. /**
  57210. * Defines a list of options used by SceneOptimizer
  57211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57212. */
  57213. export class SceneOptimizerOptions {
  57214. /**
  57215. * Defines the target frame rate to reach (60 by default)
  57216. */
  57217. targetFrameRate: number;
  57218. /**
  57219. * Defines the interval between two checkes (2000ms by default)
  57220. */
  57221. trackerDuration: number;
  57222. /**
  57223. * Gets the list of optimizations to apply
  57224. */
  57225. optimizations: SceneOptimization[];
  57226. /**
  57227. * Creates a new list of options used by SceneOptimizer
  57228. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  57229. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  57230. */
  57231. constructor(
  57232. /**
  57233. * Defines the target frame rate to reach (60 by default)
  57234. */
  57235. targetFrameRate?: number,
  57236. /**
  57237. * Defines the interval between two checkes (2000ms by default)
  57238. */
  57239. trackerDuration?: number);
  57240. /**
  57241. * Add a new optimization
  57242. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  57243. * @returns the current SceneOptimizerOptions
  57244. */
  57245. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  57246. /**
  57247. * Add a new custom optimization
  57248. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  57249. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  57250. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  57251. * @returns the current SceneOptimizerOptions
  57252. */
  57253. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  57254. /**
  57255. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  57256. * @param targetFrameRate defines the target frame rate (60 by default)
  57257. * @returns a SceneOptimizerOptions object
  57258. */
  57259. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57260. /**
  57261. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  57262. * @param targetFrameRate defines the target frame rate (60 by default)
  57263. * @returns a SceneOptimizerOptions object
  57264. */
  57265. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57266. /**
  57267. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  57268. * @param targetFrameRate defines the target frame rate (60 by default)
  57269. * @returns a SceneOptimizerOptions object
  57270. */
  57271. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  57272. }
  57273. /**
  57274. * Class used to run optimizations in order to reach a target frame rate
  57275. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  57276. */
  57277. export class SceneOptimizer implements IDisposable {
  57278. private _isRunning;
  57279. private _options;
  57280. private _scene;
  57281. private _currentPriorityLevel;
  57282. private _targetFrameRate;
  57283. private _trackerDuration;
  57284. private _currentFrameRate;
  57285. private _sceneDisposeObserver;
  57286. private _improvementMode;
  57287. /**
  57288. * Defines an observable called when the optimizer reaches the target frame rate
  57289. */
  57290. onSuccessObservable: Observable<SceneOptimizer>;
  57291. /**
  57292. * Defines an observable called when the optimizer enables an optimization
  57293. */
  57294. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  57295. /**
  57296. * Defines an observable called when the optimizer is not able to reach the target frame rate
  57297. */
  57298. onFailureObservable: Observable<SceneOptimizer>;
  57299. /**
  57300. * Gets a boolean indicating if the optimizer is in improvement mode
  57301. */
  57302. readonly isInImprovementMode: boolean;
  57303. /**
  57304. * Gets the current priority level (0 at start)
  57305. */
  57306. readonly currentPriorityLevel: number;
  57307. /**
  57308. * Gets the current frame rate checked by the SceneOptimizer
  57309. */
  57310. readonly currentFrameRate: number;
  57311. /**
  57312. * Gets or sets the current target frame rate (60 by default)
  57313. */
  57314. /**
  57315. * Gets or sets the current target frame rate (60 by default)
  57316. */
  57317. targetFrameRate: number;
  57318. /**
  57319. * Gets or sets the current interval between two checks (every 2000ms by default)
  57320. */
  57321. /**
  57322. * Gets or sets the current interval between two checks (every 2000ms by default)
  57323. */
  57324. trackerDuration: number;
  57325. /**
  57326. * Gets the list of active optimizations
  57327. */
  57328. readonly optimizations: SceneOptimization[];
  57329. /**
  57330. * Creates a new SceneOptimizer
  57331. * @param scene defines the scene to work on
  57332. * @param options defines the options to use with the SceneOptimizer
  57333. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  57334. * @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)
  57335. */
  57336. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  57337. /**
  57338. * Stops the current optimizer
  57339. */
  57340. stop(): void;
  57341. /**
  57342. * Reset the optimizer to initial step (current priority level = 0)
  57343. */
  57344. reset(): void;
  57345. /**
  57346. * Start the optimizer. By default it will try to reach a specific framerate
  57347. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  57348. */
  57349. start(): void;
  57350. private _checkCurrentState;
  57351. /**
  57352. * Release all resources
  57353. */
  57354. dispose(): void;
  57355. /**
  57356. * Helper function to create a SceneOptimizer with one single line of code
  57357. * @param scene defines the scene to work on
  57358. * @param options defines the options to use with the SceneOptimizer
  57359. * @param onSuccess defines a callback to call on success
  57360. * @param onFailure defines a callback to call on failure
  57361. * @returns the new SceneOptimizer object
  57362. */
  57363. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  57364. }
  57365. }
  57366. declare module BABYLON {
  57367. /**
  57368. * Class used to serialize a scene into a string
  57369. */
  57370. export class SceneSerializer {
  57371. /**
  57372. * Clear cache used by a previous serialization
  57373. */
  57374. static ClearCache(): void;
  57375. /**
  57376. * Serialize a scene into a JSON compatible object
  57377. * @param scene defines the scene to serialize
  57378. * @returns a JSON compatible object
  57379. */
  57380. static Serialize(scene: Scene): any;
  57381. /**
  57382. * Serialize a mesh into a JSON compatible object
  57383. * @param toSerialize defines the mesh to serialize
  57384. * @param withParents defines if parents must be serialized as well
  57385. * @param withChildren defines if children must be serialized as well
  57386. * @returns a JSON compatible object
  57387. */
  57388. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  57389. }
  57390. }
  57391. declare module BABYLON {
  57392. /**
  57393. * Class used to host texture specific utilities
  57394. */
  57395. export class TextureTools {
  57396. /**
  57397. * Uses the GPU to create a copy texture rescaled at a given size
  57398. * @param texture Texture to copy from
  57399. * @param width defines the desired width
  57400. * @param height defines the desired height
  57401. * @param useBilinearMode defines if bilinear mode has to be used
  57402. * @return the generated texture
  57403. */
  57404. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  57405. }
  57406. }
  57407. declare module BABYLON {
  57408. /**
  57409. * This represents the different options avilable for the video capture.
  57410. */
  57411. export interface VideoRecorderOptions {
  57412. /** Defines the mime type of the video */
  57413. mimeType: string;
  57414. /** Defines the video the video should be recorded at */
  57415. fps: number;
  57416. /** Defines the chunk size for the recording data */
  57417. recordChunckSize: number;
  57418. /** The audio tracks to attach to the record */
  57419. audioTracks?: MediaStreamTrack[];
  57420. }
  57421. /**
  57422. * This can helps recording videos from BabylonJS.
  57423. * This is based on the available WebRTC functionalities of the browser.
  57424. *
  57425. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  57426. */
  57427. export class VideoRecorder {
  57428. private static readonly _defaultOptions;
  57429. /**
  57430. * Returns wehther or not the VideoRecorder is available in your browser.
  57431. * @param engine Defines the Babylon Engine to check the support for
  57432. * @returns true if supported otherwise false
  57433. */
  57434. static IsSupported(engine: Engine): boolean;
  57435. private readonly _options;
  57436. private _canvas;
  57437. private _mediaRecorder;
  57438. private _recordedChunks;
  57439. private _fileName;
  57440. private _resolve;
  57441. private _reject;
  57442. /**
  57443. * True wether a recording is already in progress.
  57444. */
  57445. readonly isRecording: boolean;
  57446. /**
  57447. * Create a new VideoCapture object which can help converting what you see in Babylon to
  57448. * a video file.
  57449. * @param engine Defines the BabylonJS Engine you wish to record
  57450. * @param options Defines options that can be used to customized the capture
  57451. */
  57452. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  57453. /**
  57454. * Stops the current recording before the default capture timeout passed in the startRecording
  57455. * functions.
  57456. */
  57457. stopRecording(): void;
  57458. /**
  57459. * Starts recording the canvas for a max duration specified in parameters.
  57460. * @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.
  57461. * @param maxDuration Defines the maximum recording time in seconds.
  57462. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  57463. * @return a promise callback at the end of the recording with the video data in Blob.
  57464. */
  57465. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  57466. /**
  57467. * Releases internal resources used during the recording.
  57468. */
  57469. dispose(): void;
  57470. private _handleDataAvailable;
  57471. private _handleError;
  57472. private _handleStop;
  57473. }
  57474. }
  57475. declare module BABYLON {
  57476. /**
  57477. * Class containing a set of static utilities functions for screenshots
  57478. */
  57479. export class ScreenshotTools {
  57480. /**
  57481. * Captures a screenshot of the current rendering
  57482. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57483. * @param engine defines the rendering engine
  57484. * @param camera defines the source camera
  57485. * @param size This parameter can be set to a single number or to an object with the
  57486. * following (optional) properties: precision, width, height. If a single number is passed,
  57487. * it will be used for both width and height. If an object is passed, the screenshot size
  57488. * will be derived from the parameters. The precision property is a multiplier allowing
  57489. * rendering at a higher or lower resolution
  57490. * @param successCallback defines the callback receives a single parameter which contains the
  57491. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57492. * src parameter of an <img> to display it
  57493. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  57494. * Check your browser for supported MIME types
  57495. */
  57496. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  57497. /**
  57498. * Generates an image screenshot from the specified camera.
  57499. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  57500. * @param engine The engine to use for rendering
  57501. * @param camera The camera to use for rendering
  57502. * @param size This parameter can be set to a single number or to an object with the
  57503. * following (optional) properties: precision, width, height. If a single number is passed,
  57504. * it will be used for both width and height. If an object is passed, the screenshot size
  57505. * will be derived from the parameters. The precision property is a multiplier allowing
  57506. * rendering at a higher or lower resolution
  57507. * @param successCallback The callback receives a single parameter which contains the
  57508. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  57509. * src parameter of an <img> to display it
  57510. * @param mimeType The MIME type of the screenshot image (default: image/png).
  57511. * Check your browser for supported MIME types
  57512. * @param samples Texture samples (default: 1)
  57513. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  57514. * @param fileName A name for for the downloaded file.
  57515. */
  57516. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  57517. }
  57518. }
  57519. declare module BABYLON {
  57520. /**
  57521. * A cursor which tracks a point on a path
  57522. */
  57523. export class PathCursor {
  57524. private path;
  57525. /**
  57526. * Stores path cursor callbacks for when an onchange event is triggered
  57527. */
  57528. private _onchange;
  57529. /**
  57530. * The value of the path cursor
  57531. */
  57532. value: number;
  57533. /**
  57534. * The animation array of the path cursor
  57535. */
  57536. animations: Animation[];
  57537. /**
  57538. * Initializes the path cursor
  57539. * @param path The path to track
  57540. */
  57541. constructor(path: Path2);
  57542. /**
  57543. * Gets the cursor point on the path
  57544. * @returns A point on the path cursor at the cursor location
  57545. */
  57546. getPoint(): Vector3;
  57547. /**
  57548. * Moves the cursor ahead by the step amount
  57549. * @param step The amount to move the cursor forward
  57550. * @returns This path cursor
  57551. */
  57552. moveAhead(step?: number): PathCursor;
  57553. /**
  57554. * Moves the cursor behind by the step amount
  57555. * @param step The amount to move the cursor back
  57556. * @returns This path cursor
  57557. */
  57558. moveBack(step?: number): PathCursor;
  57559. /**
  57560. * Moves the cursor by the step amount
  57561. * If the step amount is greater than one, an exception is thrown
  57562. * @param step The amount to move the cursor
  57563. * @returns This path cursor
  57564. */
  57565. move(step: number): PathCursor;
  57566. /**
  57567. * Ensures that the value is limited between zero and one
  57568. * @returns This path cursor
  57569. */
  57570. private ensureLimits;
  57571. /**
  57572. * Runs onchange callbacks on change (used by the animation engine)
  57573. * @returns This path cursor
  57574. */
  57575. private raiseOnChange;
  57576. /**
  57577. * Executes a function on change
  57578. * @param f A path cursor onchange callback
  57579. * @returns This path cursor
  57580. */
  57581. onchange(f: (cursor: PathCursor) => void): PathCursor;
  57582. }
  57583. }
  57584. declare module BABYLON {
  57585. /** @hidden */
  57586. export var blurPixelShader: {
  57587. name: string;
  57588. shader: string;
  57589. };
  57590. }
  57591. declare module BABYLON {
  57592. /** @hidden */
  57593. export var bones300Declaration: {
  57594. name: string;
  57595. shader: string;
  57596. };
  57597. }
  57598. declare module BABYLON {
  57599. /** @hidden */
  57600. export var instances300Declaration: {
  57601. name: string;
  57602. shader: string;
  57603. };
  57604. }
  57605. declare module BABYLON {
  57606. /** @hidden */
  57607. export var pointCloudVertexDeclaration: {
  57608. name: string;
  57609. shader: string;
  57610. };
  57611. }
  57612. // Mixins
  57613. interface Window {
  57614. mozIndexedDB: IDBFactory;
  57615. webkitIndexedDB: IDBFactory;
  57616. msIndexedDB: IDBFactory;
  57617. webkitURL: typeof URL;
  57618. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  57619. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  57620. WebGLRenderingContext: WebGLRenderingContext;
  57621. MSGesture: MSGesture;
  57622. CANNON: any;
  57623. AudioContext: AudioContext;
  57624. webkitAudioContext: AudioContext;
  57625. PointerEvent: any;
  57626. Math: Math;
  57627. Uint8Array: Uint8ArrayConstructor;
  57628. Float32Array: Float32ArrayConstructor;
  57629. mozURL: typeof URL;
  57630. msURL: typeof URL;
  57631. VRFrameData: any; // WebVR, from specs 1.1
  57632. DracoDecoderModule: any;
  57633. setImmediate(handler: (...args: any[]) => void): number;
  57634. }
  57635. interface HTMLCanvasElement {
  57636. requestPointerLock(): void;
  57637. msRequestPointerLock?(): void;
  57638. mozRequestPointerLock?(): void;
  57639. webkitRequestPointerLock?(): void;
  57640. /** Track wether a record is in progress */
  57641. isRecording: boolean;
  57642. /** Capture Stream method defined by some browsers */
  57643. captureStream(fps?: number): MediaStream;
  57644. }
  57645. interface CanvasRenderingContext2D {
  57646. msImageSmoothingEnabled: boolean;
  57647. }
  57648. interface MouseEvent {
  57649. mozMovementX: number;
  57650. mozMovementY: number;
  57651. webkitMovementX: number;
  57652. webkitMovementY: number;
  57653. msMovementX: number;
  57654. msMovementY: number;
  57655. }
  57656. interface Navigator {
  57657. mozGetVRDevices: (any: any) => any;
  57658. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57659. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57660. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  57661. webkitGetGamepads(): Gamepad[];
  57662. msGetGamepads(): Gamepad[];
  57663. webkitGamepads(): Gamepad[];
  57664. }
  57665. interface HTMLVideoElement {
  57666. mozSrcObject: any;
  57667. }
  57668. interface Math {
  57669. fround(x: number): number;
  57670. imul(a: number, b: number): number;
  57671. }
  57672. interface WebGLRenderingContext {
  57673. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  57674. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  57675. vertexAttribDivisor(index: number, divisor: number): void;
  57676. createVertexArray(): any;
  57677. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  57678. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  57679. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  57680. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  57681. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57682. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  57683. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  57684. // Queries
  57685. createQuery(): WebGLQuery;
  57686. deleteQuery(query: WebGLQuery): void;
  57687. beginQuery(target: number, query: WebGLQuery): void;
  57688. endQuery(target: number): void;
  57689. getQueryParameter(query: WebGLQuery, pname: number): any;
  57690. getQuery(target: number, pname: number): any;
  57691. MAX_SAMPLES: number;
  57692. RGBA8: number;
  57693. READ_FRAMEBUFFER: number;
  57694. DRAW_FRAMEBUFFER: number;
  57695. UNIFORM_BUFFER: number;
  57696. HALF_FLOAT_OES: number;
  57697. RGBA16F: number;
  57698. RGBA32F: number;
  57699. R32F: number;
  57700. RG32F: number;
  57701. RGB32F: number;
  57702. R16F: number;
  57703. RG16F: number;
  57704. RGB16F: number;
  57705. RED: number;
  57706. RG: number;
  57707. R8: number;
  57708. RG8: number;
  57709. UNSIGNED_INT_24_8: number;
  57710. DEPTH24_STENCIL8: number;
  57711. /* Multiple Render Targets */
  57712. drawBuffers(buffers: number[]): void;
  57713. readBuffer(src: number): void;
  57714. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  57715. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  57716. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  57717. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  57718. // Occlusion Query
  57719. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  57720. ANY_SAMPLES_PASSED: number;
  57721. QUERY_RESULT_AVAILABLE: number;
  57722. QUERY_RESULT: number;
  57723. }
  57724. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  57725. }
  57726. interface EXT_disjoint_timer_query {
  57727. QUERY_COUNTER_BITS_EXT: number;
  57728. TIME_ELAPSED_EXT: number;
  57729. TIMESTAMP_EXT: number;
  57730. GPU_DISJOINT_EXT: number;
  57731. QUERY_RESULT_EXT: number;
  57732. QUERY_RESULT_AVAILABLE_EXT: number;
  57733. queryCounterEXT(query: WebGLQuery, target: number): void;
  57734. createQueryEXT(): WebGLQuery;
  57735. beginQueryEXT(target: number, query: WebGLQuery): void;
  57736. endQueryEXT(target: number): void;
  57737. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  57738. deleteQueryEXT(query: WebGLQuery): void;
  57739. }
  57740. interface WebGLUniformLocation { private _currentState: any;
  57741. }
  57742. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  57743. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  57744. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  57745. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57746. interface WebGLRenderingContext {
  57747. readonly RASTERIZER_DISCARD: number;
  57748. readonly DEPTH_COMPONENT24: number;
  57749. readonly TEXTURE_3D: number;
  57750. readonly TEXTURE_2D_ARRAY: number;
  57751. readonly TEXTURE_COMPARE_FUNC: number;
  57752. readonly TEXTURE_COMPARE_MODE: number;
  57753. readonly COMPARE_REF_TO_TEXTURE: number;
  57754. readonly TEXTURE_WRAP_R: number;
  57755. readonly HALF_FLOAT: number;
  57756. readonly RGB8: number;
  57757. readonly RED_INTEGER: number;
  57758. readonly RG_INTEGER: number;
  57759. readonly RGB_INTEGER: number;
  57760. readonly RGBA_INTEGER: number;
  57761. readonly R8_SNORM: number;
  57762. readonly RG8_SNORM: number;
  57763. readonly RGB8_SNORM: number;
  57764. readonly RGBA8_SNORM: number;
  57765. readonly R8I: number;
  57766. readonly RG8I: number;
  57767. readonly RGB8I: number;
  57768. readonly RGBA8I: number;
  57769. readonly R8UI: number;
  57770. readonly RG8UI: number;
  57771. readonly RGB8UI: number;
  57772. readonly RGBA8UI: number;
  57773. readonly R16I: number;
  57774. readonly RG16I: number;
  57775. readonly RGB16I: number;
  57776. readonly RGBA16I: number;
  57777. readonly R16UI: number;
  57778. readonly RG16UI: number;
  57779. readonly RGB16UI: number;
  57780. readonly RGBA16UI: number;
  57781. readonly R32I: number;
  57782. readonly RG32I: number;
  57783. readonly RGB32I: number;
  57784. readonly RGBA32I: number;
  57785. readonly R32UI: number;
  57786. readonly RG32UI: number;
  57787. readonly RGB32UI: number;
  57788. readonly RGBA32UI: number;
  57789. readonly RGB10_A2UI: number;
  57790. readonly R11F_G11F_B10F: number;
  57791. readonly RGB9_E5: number;
  57792. readonly RGB10_A2: number;
  57793. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  57794. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  57795. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  57796. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  57797. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  57798. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  57799. 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;
  57800. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  57801. readonly TRANSFORM_FEEDBACK: number;
  57802. readonly INTERLEAVED_ATTRIBS: number;
  57803. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  57804. createTransformFeedback(): WebGLTransformFeedback;
  57805. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  57806. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  57807. beginTransformFeedback(primitiveMode: number): void;
  57808. endTransformFeedback(): void;
  57809. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  57810. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57811. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57812. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  57813. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  57814. }
  57815. interface ImageBitmap {
  57816. readonly width: number;
  57817. readonly height: number;
  57818. close(): void;
  57819. }
  57820. interface WebGLQuery extends WebGLObject {
  57821. }
  57822. declare var WebGLQuery: {
  57823. prototype: WebGLQuery;
  57824. new(): WebGLQuery;
  57825. };
  57826. interface WebGLSampler extends WebGLObject {
  57827. }
  57828. declare var WebGLSampler: {
  57829. prototype: WebGLSampler;
  57830. new(): WebGLSampler;
  57831. };
  57832. interface WebGLSync extends WebGLObject {
  57833. }
  57834. declare var WebGLSync: {
  57835. prototype: WebGLSync;
  57836. new(): WebGLSync;
  57837. };
  57838. interface WebGLTransformFeedback extends WebGLObject {
  57839. }
  57840. declare var WebGLTransformFeedback: {
  57841. prototype: WebGLTransformFeedback;
  57842. new(): WebGLTransformFeedback;
  57843. };
  57844. interface WebGLVertexArrayObject extends WebGLObject {
  57845. }
  57846. declare var WebGLVertexArrayObject: {
  57847. prototype: WebGLVertexArrayObject;
  57848. new(): WebGLVertexArrayObject;
  57849. };
  57850. // Type definitions for WebVR API
  57851. // Project: https://w3c.github.io/webvr/
  57852. // Definitions by: six a <https://github.com/lostfictions>
  57853. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  57854. interface VRDisplay extends EventTarget {
  57855. /**
  57856. * Dictionary of capabilities describing the VRDisplay.
  57857. */
  57858. readonly capabilities: VRDisplayCapabilities;
  57859. /**
  57860. * z-depth defining the far plane of the eye view frustum
  57861. * enables mapping of values in the render target depth
  57862. * attachment to scene coordinates. Initially set to 10000.0.
  57863. */
  57864. depthFar: number;
  57865. /**
  57866. * z-depth defining the near plane of the eye view frustum
  57867. * enables mapping of values in the render target depth
  57868. * attachment to scene coordinates. Initially set to 0.01.
  57869. */
  57870. depthNear: number;
  57871. /**
  57872. * An identifier for this distinct VRDisplay. Used as an
  57873. * association point in the Gamepad API.
  57874. */
  57875. readonly displayId: number;
  57876. /**
  57877. * A display name, a user-readable name identifying it.
  57878. */
  57879. readonly displayName: string;
  57880. readonly isConnected: boolean;
  57881. readonly isPresenting: boolean;
  57882. /**
  57883. * If this VRDisplay supports room-scale experiences, the optional
  57884. * stage attribute contains details on the room-scale parameters.
  57885. */
  57886. readonly stageParameters: VRStageParameters | null;
  57887. /**
  57888. * Passing the value returned by `requestAnimationFrame` to
  57889. * `cancelAnimationFrame` will unregister the callback.
  57890. * @param handle Define the hanle of the request to cancel
  57891. */
  57892. cancelAnimationFrame(handle: number): void;
  57893. /**
  57894. * Stops presenting to the VRDisplay.
  57895. * @returns a promise to know when it stopped
  57896. */
  57897. exitPresent(): Promise<void>;
  57898. /**
  57899. * Return the current VREyeParameters for the given eye.
  57900. * @param whichEye Define the eye we want the parameter for
  57901. * @returns the eye parameters
  57902. */
  57903. getEyeParameters(whichEye: string): VREyeParameters;
  57904. /**
  57905. * Populates the passed VRFrameData with the information required to render
  57906. * the current frame.
  57907. * @param frameData Define the data structure to populate
  57908. * @returns true if ok otherwise false
  57909. */
  57910. getFrameData(frameData: VRFrameData): boolean;
  57911. /**
  57912. * Get the layers currently being presented.
  57913. * @returns the list of VR layers
  57914. */
  57915. getLayers(): VRLayer[];
  57916. /**
  57917. * Return a VRPose containing the future predicted pose of the VRDisplay
  57918. * when the current frame will be presented. The value returned will not
  57919. * change until JavaScript has returned control to the browser.
  57920. *
  57921. * The VRPose will contain the position, orientation, velocity,
  57922. * and acceleration of each of these properties.
  57923. * @returns the pose object
  57924. */
  57925. getPose(): VRPose;
  57926. /**
  57927. * Return the current instantaneous pose of the VRDisplay, with no
  57928. * prediction applied.
  57929. * @returns the current instantaneous pose
  57930. */
  57931. getImmediatePose(): VRPose;
  57932. /**
  57933. * The callback passed to `requestAnimationFrame` will be called
  57934. * any time a new frame should be rendered. When the VRDisplay is
  57935. * presenting the callback will be called at the native refresh
  57936. * rate of the HMD. When not presenting this function acts
  57937. * identically to how window.requestAnimationFrame acts. Content should
  57938. * make no assumptions of frame rate or vsync behavior as the HMD runs
  57939. * asynchronously from other displays and at differing refresh rates.
  57940. * @param callback Define the eaction to run next frame
  57941. * @returns the request handle it
  57942. */
  57943. requestAnimationFrame(callback: FrameRequestCallback): number;
  57944. /**
  57945. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  57946. * Repeat calls while already presenting will update the VRLayers being displayed.
  57947. * @param layers Define the list of layer to present
  57948. * @returns a promise to know when the request has been fulfilled
  57949. */
  57950. requestPresent(layers: VRLayer[]): Promise<void>;
  57951. /**
  57952. * Reset the pose for this display, treating its current position and
  57953. * orientation as the "origin/zero" values. VRPose.position,
  57954. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  57955. * updated when calling resetPose(). This should be called in only
  57956. * sitting-space experiences.
  57957. */
  57958. resetPose(): void;
  57959. /**
  57960. * The VRLayer provided to the VRDisplay will be captured and presented
  57961. * in the HMD. Calling this function has the same effect on the source
  57962. * canvas as any other operation that uses its source image, and canvases
  57963. * created without preserveDrawingBuffer set to true will be cleared.
  57964. * @param pose Define the pose to submit
  57965. */
  57966. submitFrame(pose?: VRPose): void;
  57967. }
  57968. declare var VRDisplay: {
  57969. prototype: VRDisplay;
  57970. new(): VRDisplay;
  57971. };
  57972. interface VRLayer {
  57973. leftBounds?: number[] | Float32Array | null;
  57974. rightBounds?: number[] | Float32Array | null;
  57975. source?: HTMLCanvasElement | null;
  57976. }
  57977. interface VRDisplayCapabilities {
  57978. readonly canPresent: boolean;
  57979. readonly hasExternalDisplay: boolean;
  57980. readonly hasOrientation: boolean;
  57981. readonly hasPosition: boolean;
  57982. readonly maxLayers: number;
  57983. }
  57984. interface VREyeParameters {
  57985. /** @deprecated */
  57986. readonly fieldOfView: VRFieldOfView;
  57987. readonly offset: Float32Array;
  57988. readonly renderHeight: number;
  57989. readonly renderWidth: number;
  57990. }
  57991. interface VRFieldOfView {
  57992. readonly downDegrees: number;
  57993. readonly leftDegrees: number;
  57994. readonly rightDegrees: number;
  57995. readonly upDegrees: number;
  57996. }
  57997. interface VRFrameData {
  57998. readonly leftProjectionMatrix: Float32Array;
  57999. readonly leftViewMatrix: Float32Array;
  58000. readonly pose: VRPose;
  58001. readonly rightProjectionMatrix: Float32Array;
  58002. readonly rightViewMatrix: Float32Array;
  58003. readonly timestamp: number;
  58004. }
  58005. interface VRPose {
  58006. readonly angularAcceleration: Float32Array | null;
  58007. readonly angularVelocity: Float32Array | null;
  58008. readonly linearAcceleration: Float32Array | null;
  58009. readonly linearVelocity: Float32Array | null;
  58010. readonly orientation: Float32Array | null;
  58011. readonly position: Float32Array | null;
  58012. readonly timestamp: number;
  58013. }
  58014. interface VRStageParameters {
  58015. sittingToStandingTransform?: Float32Array;
  58016. sizeX?: number;
  58017. sizeY?: number;
  58018. }
  58019. interface Navigator {
  58020. getVRDisplays(): Promise<VRDisplay[]>;
  58021. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  58022. }
  58023. interface Window {
  58024. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  58025. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  58026. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  58027. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58028. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  58029. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  58030. }
  58031. interface Gamepad {
  58032. readonly displayId: number;
  58033. }
  58034. interface XRDevice {
  58035. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  58036. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  58037. }
  58038. interface XRSession {
  58039. getInputSources(): Array<any>;
  58040. baseLayer: XRWebGLLayer;
  58041. requestFrameOfReference(type: string): Promise<void>;
  58042. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  58043. end(): Promise<void>;
  58044. requestAnimationFrame: Function;
  58045. addEventListener: Function;
  58046. }
  58047. interface XRSessionCreationOptions {
  58048. outputContext?: WebGLRenderingContext | null;
  58049. immersive?: boolean;
  58050. environmentIntegration?: boolean;
  58051. }
  58052. interface XRLayer {
  58053. getViewport: Function;
  58054. framebufferWidth: number;
  58055. framebufferHeight: number;
  58056. }
  58057. interface XRView {
  58058. projectionMatrix: Float32Array;
  58059. }
  58060. interface XRFrame {
  58061. getDevicePose: Function;
  58062. getInputPose: Function;
  58063. views: Array<XRView>;
  58064. baseLayer: XRLayer;
  58065. }
  58066. interface XRFrameOfReference {
  58067. }
  58068. interface XRWebGLLayer extends XRLayer {
  58069. framebuffer: WebGLFramebuffer;
  58070. }
  58071. declare var XRWebGLLayer: {
  58072. prototype: XRWebGLLayer;
  58073. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  58074. };
  58075. declare module BABYLON.GUI {
  58076. /**
  58077. * Class used to specific a value and its associated unit
  58078. */
  58079. export class ValueAndUnit {
  58080. /** defines the unit to store */
  58081. unit: number;
  58082. /** defines a boolean indicating if the value can be negative */
  58083. negativeValueAllowed: boolean;
  58084. private _value;
  58085. private _originalUnit;
  58086. /**
  58087. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  58088. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58089. */
  58090. ignoreAdaptiveScaling: boolean;
  58091. /**
  58092. * Creates a new ValueAndUnit
  58093. * @param value defines the value to store
  58094. * @param unit defines the unit to store
  58095. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  58096. */
  58097. constructor(value: number,
  58098. /** defines the unit to store */
  58099. unit?: number,
  58100. /** defines a boolean indicating if the value can be negative */
  58101. negativeValueAllowed?: boolean);
  58102. /** Gets a boolean indicating if the value is a percentage */
  58103. readonly isPercentage: boolean;
  58104. /** Gets a boolean indicating if the value is store as pixel */
  58105. readonly isPixel: boolean;
  58106. /** Gets direct internal value */
  58107. readonly internalValue: number;
  58108. /**
  58109. * Gets value as pixel
  58110. * @param host defines the root host
  58111. * @param refValue defines the reference value for percentages
  58112. * @returns the value as pixel
  58113. */
  58114. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  58115. /**
  58116. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  58117. * @param value defines the value to store
  58118. * @param unit defines the unit to store
  58119. * @returns the current ValueAndUnit
  58120. */
  58121. updateInPlace(value: number, unit?: number): ValueAndUnit;
  58122. /**
  58123. * Gets the value accordingly to its unit
  58124. * @param host defines the root host
  58125. * @returns the value
  58126. */
  58127. getValue(host: AdvancedDynamicTexture): number;
  58128. /**
  58129. * Gets a string representation of the value
  58130. * @param host defines the root host
  58131. * @param decimals defines an optional number of decimals to display
  58132. * @returns a string
  58133. */
  58134. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  58135. /**
  58136. * Store a value parsed from a string
  58137. * @param source defines the source string
  58138. * @returns true if the value was successfully parsed
  58139. */
  58140. fromString(source: string | number): boolean;
  58141. private static _Regex;
  58142. private static _UNITMODE_PERCENTAGE;
  58143. private static _UNITMODE_PIXEL;
  58144. /** UNITMODE_PERCENTAGE */
  58145. static readonly UNITMODE_PERCENTAGE: number;
  58146. /** UNITMODE_PIXEL */
  58147. static readonly UNITMODE_PIXEL: number;
  58148. }
  58149. }
  58150. declare module BABYLON.GUI {
  58151. /**
  58152. * Define a style used by control to automatically setup properties based on a template.
  58153. * Only support font related properties so far
  58154. */
  58155. export class Style implements BABYLON.IDisposable {
  58156. private _fontFamily;
  58157. private _fontStyle;
  58158. private _fontWeight;
  58159. /** @hidden */ private _host: AdvancedDynamicTexture;
  58160. /** @hidden */ private _fontSize: ValueAndUnit;
  58161. /**
  58162. * BABYLON.Observable raised when the style values are changed
  58163. */
  58164. onChangedObservable: BABYLON.Observable<Style>;
  58165. /**
  58166. * Creates a new style object
  58167. * @param host defines the AdvancedDynamicTexture which hosts this style
  58168. */
  58169. constructor(host: AdvancedDynamicTexture);
  58170. /**
  58171. * Gets or sets the font size
  58172. */
  58173. fontSize: string | number;
  58174. /**
  58175. * Gets or sets the font family
  58176. */
  58177. fontFamily: string;
  58178. /**
  58179. * Gets or sets the font style
  58180. */
  58181. fontStyle: string;
  58182. /** Gets or sets font weight */
  58183. fontWeight: string;
  58184. /** Dispose all associated resources */
  58185. dispose(): void;
  58186. }
  58187. }
  58188. declare module BABYLON.GUI {
  58189. /**
  58190. * Class used to transport BABYLON.Vector2 information for pointer events
  58191. */
  58192. export class Vector2WithInfo extends BABYLON.Vector2 {
  58193. /** defines the current mouse button index */
  58194. buttonIndex: number;
  58195. /**
  58196. * Creates a new Vector2WithInfo
  58197. * @param source defines the vector2 data to transport
  58198. * @param buttonIndex defines the current mouse button index
  58199. */
  58200. constructor(source: BABYLON.Vector2,
  58201. /** defines the current mouse button index */
  58202. buttonIndex?: number);
  58203. }
  58204. /** Class used to provide 2D matrix features */
  58205. export class Matrix2D {
  58206. /** Gets the internal array of 6 floats used to store matrix data */
  58207. m: Float32Array;
  58208. /**
  58209. * Creates a new matrix
  58210. * @param m00 defines value for (0, 0)
  58211. * @param m01 defines value for (0, 1)
  58212. * @param m10 defines value for (1, 0)
  58213. * @param m11 defines value for (1, 1)
  58214. * @param m20 defines value for (2, 0)
  58215. * @param m21 defines value for (2, 1)
  58216. */
  58217. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  58218. /**
  58219. * Fills the matrix from direct values
  58220. * @param m00 defines value for (0, 0)
  58221. * @param m01 defines value for (0, 1)
  58222. * @param m10 defines value for (1, 0)
  58223. * @param m11 defines value for (1, 1)
  58224. * @param m20 defines value for (2, 0)
  58225. * @param m21 defines value for (2, 1)
  58226. * @returns the current modified matrix
  58227. */
  58228. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  58229. /**
  58230. * Gets matrix determinant
  58231. * @returns the determinant
  58232. */
  58233. determinant(): number;
  58234. /**
  58235. * Inverses the matrix and stores it in a target matrix
  58236. * @param result defines the target matrix
  58237. * @returns the current matrix
  58238. */
  58239. invertToRef(result: Matrix2D): Matrix2D;
  58240. /**
  58241. * Multiplies the current matrix with another one
  58242. * @param other defines the second operand
  58243. * @param result defines the target matrix
  58244. * @returns the current matrix
  58245. */
  58246. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  58247. /**
  58248. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  58249. * @param x defines the x coordinate to transform
  58250. * @param y defines the x coordinate to transform
  58251. * @param result defines the target vector2
  58252. * @returns the current matrix
  58253. */
  58254. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  58255. /**
  58256. * Creates an identity matrix
  58257. * @returns a new matrix
  58258. */
  58259. static Identity(): Matrix2D;
  58260. /**
  58261. * Creates a translation matrix and stores it in a target matrix
  58262. * @param x defines the x coordinate of the translation
  58263. * @param y defines the y coordinate of the translation
  58264. * @param result defines the target matrix
  58265. */
  58266. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  58267. /**
  58268. * Creates a scaling matrix and stores it in a target matrix
  58269. * @param x defines the x coordinate of the scaling
  58270. * @param y defines the y coordinate of the scaling
  58271. * @param result defines the target matrix
  58272. */
  58273. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  58274. /**
  58275. * Creates a rotation matrix and stores it in a target matrix
  58276. * @param angle defines the rotation angle
  58277. * @param result defines the target matrix
  58278. */
  58279. static RotationToRef(angle: number, result: Matrix2D): void;
  58280. private static _TempPreTranslationMatrix;
  58281. private static _TempPostTranslationMatrix;
  58282. private static _TempRotationMatrix;
  58283. private static _TempScalingMatrix;
  58284. private static _TempCompose0;
  58285. private static _TempCompose1;
  58286. private static _TempCompose2;
  58287. /**
  58288. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  58289. * @param tx defines the x coordinate of the translation
  58290. * @param ty defines the y coordinate of the translation
  58291. * @param angle defines the rotation angle
  58292. * @param scaleX defines the x coordinate of the scaling
  58293. * @param scaleY defines the y coordinate of the scaling
  58294. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  58295. * @param result defines the target matrix
  58296. */
  58297. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  58298. }
  58299. }
  58300. declare module BABYLON.GUI {
  58301. /**
  58302. * Class used to store 2D control sizes
  58303. */
  58304. export class Measure {
  58305. /** defines left coordinate */
  58306. left: number;
  58307. /** defines top coordinate */
  58308. top: number;
  58309. /** defines width dimension */
  58310. width: number;
  58311. /** defines height dimension */
  58312. height: number;
  58313. /**
  58314. * Creates a new measure
  58315. * @param left defines left coordinate
  58316. * @param top defines top coordinate
  58317. * @param width defines width dimension
  58318. * @param height defines height dimension
  58319. */
  58320. constructor(
  58321. /** defines left coordinate */
  58322. left: number,
  58323. /** defines top coordinate */
  58324. top: number,
  58325. /** defines width dimension */
  58326. width: number,
  58327. /** defines height dimension */
  58328. height: number);
  58329. /**
  58330. * Copy from another measure
  58331. * @param other defines the other measure to copy from
  58332. */
  58333. copyFrom(other: Measure): void;
  58334. /**
  58335. * Copy from a group of 4 floats
  58336. * @param left defines left coordinate
  58337. * @param top defines top coordinate
  58338. * @param width defines width dimension
  58339. * @param height defines height dimension
  58340. */
  58341. copyFromFloats(left: number, top: number, width: number, height: number): void;
  58342. /**
  58343. * Computes the axis aligned bounding box measure for two given measures
  58344. * @param a Input measure
  58345. * @param b Input measure
  58346. * @param result the resulting bounding measure
  58347. */
  58348. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  58349. /**
  58350. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  58351. * @param transform the matrix to transform the measure before computing the AABB
  58352. * @param result the resulting AABB
  58353. */
  58354. transformToRef(transform: Matrix2D, result: Measure): void;
  58355. /**
  58356. * Check equality between this measure and another one
  58357. * @param other defines the other measures
  58358. * @returns true if both measures are equals
  58359. */
  58360. isEqualsTo(other: Measure): boolean;
  58361. /**
  58362. * Creates an empty measure
  58363. * @returns a new measure
  58364. */
  58365. static Empty(): Measure;
  58366. }
  58367. }
  58368. declare module BABYLON.GUI {
  58369. /**
  58370. * Interface used to define a control that can receive focus
  58371. */
  58372. export interface IFocusableControl {
  58373. /**
  58374. * Function called when the control receives the focus
  58375. */
  58376. onFocus(): void;
  58377. /**
  58378. * Function called when the control loses the focus
  58379. */
  58380. onBlur(): void;
  58381. /**
  58382. * Function called to let the control handle keyboard events
  58383. * @param evt defines the current keyboard event
  58384. */
  58385. processKeyboard(evt: KeyboardEvent): void;
  58386. /**
  58387. * Function called to get the list of controls that should not steal the focus from this control
  58388. * @returns an array of controls
  58389. */
  58390. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  58391. }
  58392. /**
  58393. * Class used to create texture to support 2D GUI elements
  58394. * @see http://doc.babylonjs.com/how_to/gui
  58395. */
  58396. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  58397. private _isDirty;
  58398. private _renderObserver;
  58399. private _resizeObserver;
  58400. private _preKeyboardObserver;
  58401. private _pointerMoveObserver;
  58402. private _pointerObserver;
  58403. private _canvasPointerOutObserver;
  58404. private _background;
  58405. /** @hidden */ private _rootContainer: Container;
  58406. /** @hidden */ private _lastPickedControl: Control;
  58407. /** @hidden */ private _lastControlOver: {
  58408. [pointerId: number]: Control;
  58409. };
  58410. /** @hidden */ private _lastControlDown: {
  58411. [pointerId: number]: Control;
  58412. };
  58413. /** @hidden */ private _capturingControl: {
  58414. [pointerId: number]: Control;
  58415. };
  58416. /** @hidden */ private _shouldBlockPointer: boolean;
  58417. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  58418. /** @hidden */ private _linkedControls: Control[];
  58419. private _isFullscreen;
  58420. private _fullscreenViewport;
  58421. private _idealWidth;
  58422. private _idealHeight;
  58423. private _useSmallestIdeal;
  58424. private _renderAtIdealSize;
  58425. private _focusedControl;
  58426. private _blockNextFocusCheck;
  58427. private _renderScale;
  58428. private _rootCanvas;
  58429. private _cursorChanged;
  58430. /**
  58431. * Define type to string to ensure compatibility across browsers
  58432. * Safari doesn't support DataTransfer constructor
  58433. */
  58434. private _clipboardData;
  58435. /**
  58436. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  58437. */
  58438. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  58439. /**
  58440. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  58441. */
  58442. onControlPickedObservable: BABYLON.Observable<Control>;
  58443. /**
  58444. * BABYLON.Observable event triggered before layout is evaluated
  58445. */
  58446. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58447. /**
  58448. * BABYLON.Observable event triggered after the layout was evaluated
  58449. */
  58450. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58451. /**
  58452. * BABYLON.Observable event triggered before the texture is rendered
  58453. */
  58454. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58455. /**
  58456. * BABYLON.Observable event triggered after the texture was rendered
  58457. */
  58458. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  58459. /**
  58460. * Gets or sets a boolean defining if alpha is stored as premultiplied
  58461. */
  58462. premulAlpha: boolean;
  58463. /**
  58464. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  58465. * Useful when you want more antialiasing
  58466. */
  58467. renderScale: number;
  58468. /** Gets or sets the background color */
  58469. background: string;
  58470. /**
  58471. * Gets or sets the ideal width used to design controls.
  58472. * The GUI will then rescale everything accordingly
  58473. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58474. */
  58475. idealWidth: number;
  58476. /**
  58477. * Gets or sets the ideal height used to design controls.
  58478. * The GUI will then rescale everything accordingly
  58479. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58480. */
  58481. idealHeight: number;
  58482. /**
  58483. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  58484. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58485. */
  58486. useSmallestIdeal: boolean;
  58487. /**
  58488. * Gets or sets a boolean indicating if adaptive scaling must be used
  58489. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  58490. */
  58491. renderAtIdealSize: boolean;
  58492. /**
  58493. * Gets the underlying layer used to render the texture when in fullscreen mode
  58494. */
  58495. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  58496. /**
  58497. * Gets the root container control
  58498. */
  58499. readonly rootContainer: Container;
  58500. /**
  58501. * Returns an array containing the root container.
  58502. * This is mostly used to let the Inspector introspects the ADT
  58503. * @returns an array containing the rootContainer
  58504. */
  58505. getChildren(): Array<Container>;
  58506. /**
  58507. * Will return all controls that are inside this texture
  58508. * @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
  58509. * @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
  58510. * @return all child controls
  58511. */
  58512. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  58513. /**
  58514. * Gets or sets the current focused control
  58515. */
  58516. focusedControl: BABYLON.Nullable<IFocusableControl>;
  58517. /**
  58518. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  58519. */
  58520. isForeground: boolean;
  58521. /**
  58522. * Gets or set information about clipboardData
  58523. */
  58524. clipboardData: string;
  58525. /**
  58526. * Creates a new AdvancedDynamicTexture
  58527. * @param name defines the name of the texture
  58528. * @param width defines the width of the texture
  58529. * @param height defines the height of the texture
  58530. * @param scene defines the hosting scene
  58531. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  58532. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  58533. */
  58534. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  58535. /**
  58536. * Get the current class name of the texture useful for serialization or dynamic coding.
  58537. * @returns "AdvancedDynamicTexture"
  58538. */
  58539. getClassName(): string;
  58540. /**
  58541. * Function used to execute a function on all controls
  58542. * @param func defines the function to execute
  58543. * @param container defines the container where controls belong. If null the root container will be used
  58544. */
  58545. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  58546. private _useInvalidateRectOptimization;
  58547. /**
  58548. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  58549. */
  58550. useInvalidateRectOptimization: boolean;
  58551. private _invalidatedRectangle;
  58552. /**
  58553. * Invalidates a rectangle area on the gui texture
  58554. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  58555. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  58556. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  58557. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  58558. */
  58559. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  58560. /**
  58561. * Marks the texture as dirty forcing a complete update
  58562. */
  58563. markAsDirty(): void;
  58564. /**
  58565. * Helper function used to create a new style
  58566. * @returns a new style
  58567. * @see http://doc.babylonjs.com/how_to/gui#styles
  58568. */
  58569. createStyle(): Style;
  58570. /**
  58571. * Adds a new control to the root container
  58572. * @param control defines the control to add
  58573. * @returns the current texture
  58574. */
  58575. addControl(control: Control): AdvancedDynamicTexture;
  58576. /**
  58577. * Removes a control from the root container
  58578. * @param control defines the control to remove
  58579. * @returns the current texture
  58580. */
  58581. removeControl(control: Control): AdvancedDynamicTexture;
  58582. /**
  58583. * Release all resources
  58584. */
  58585. dispose(): void;
  58586. private _onResize;
  58587. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  58588. /**
  58589. * Get screen coordinates for a vector3
  58590. * @param position defines the position to project
  58591. * @param worldMatrix defines the world matrix to use
  58592. * @returns the projected position
  58593. */
  58594. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  58595. private _checkUpdate;
  58596. private _clearMeasure;
  58597. private _render;
  58598. /** @hidden */ private _changeCursor(cursor: string): void;
  58599. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  58600. private _doPicking;
  58601. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  58602. [pointerId: number]: Control;
  58603. }, control: Control): void;
  58604. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  58605. /** Attach to all scene events required to support pointer events */
  58606. attach(): void;
  58607. /** @hidden */
  58608. private onClipboardCopy;
  58609. /** @hidden */
  58610. private onClipboardCut;
  58611. /** @hidden */
  58612. private onClipboardPaste;
  58613. /**
  58614. * Register the clipboard Events onto the canvas
  58615. */
  58616. registerClipboardEvents(): void;
  58617. /**
  58618. * Unregister the clipboard Events from the canvas
  58619. */
  58620. unRegisterClipboardEvents(): void;
  58621. /**
  58622. * Connect the texture to a hosting mesh to enable interactions
  58623. * @param mesh defines the mesh to attach to
  58624. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  58625. */
  58626. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  58627. /**
  58628. * Move the focus to a specific control
  58629. * @param control defines the control which will receive the focus
  58630. */
  58631. moveFocusToControl(control: IFocusableControl): void;
  58632. private _manageFocus;
  58633. private _attachToOnPointerOut;
  58634. /**
  58635. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  58636. * @param mesh defines the mesh which will receive the texture
  58637. * @param width defines the texture width (1024 by default)
  58638. * @param height defines the texture height (1024 by default)
  58639. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  58640. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  58641. * @returns a new AdvancedDynamicTexture
  58642. */
  58643. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  58644. /**
  58645. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  58646. * In this mode the texture will rely on a layer for its rendering.
  58647. * This allows it to be treated like any other layer.
  58648. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  58649. * LayerMask is set through advancedTexture.layer.layerMask
  58650. * @param name defines name for the texture
  58651. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  58652. * @param scene defines the hsoting scene
  58653. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  58654. * @returns a new AdvancedDynamicTexture
  58655. */
  58656. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  58657. }
  58658. }
  58659. declare module BABYLON.GUI {
  58660. /**
  58661. * Root class used for all 2D controls
  58662. * @see http://doc.babylonjs.com/how_to/gui#controls
  58663. */
  58664. export class Control {
  58665. /** defines the name of the control */
  58666. name?: string | undefined;
  58667. /**
  58668. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  58669. */
  58670. static AllowAlphaInheritance: boolean;
  58671. private _alpha;
  58672. private _alphaSet;
  58673. private _zIndex;
  58674. /** @hidden */ private _host: AdvancedDynamicTexture;
  58675. /** Gets or sets the control parent */
  58676. parent: BABYLON.Nullable<Container>;
  58677. /** @hidden */ private _currentMeasure: Measure;
  58678. private _fontFamily;
  58679. private _fontStyle;
  58680. private _fontWeight;
  58681. private _fontSize;
  58682. private _font;
  58683. /** @hidden */ private _width: ValueAndUnit;
  58684. /** @hidden */ private _height: ValueAndUnit;
  58685. /** @hidden */
  58686. protected _fontOffset: {
  58687. ascent: number;
  58688. height: number;
  58689. descent: number;
  58690. };
  58691. private _color;
  58692. private _style;
  58693. private _styleObserver;
  58694. /** @hidden */
  58695. protected _horizontalAlignment: number;
  58696. /** @hidden */
  58697. protected _verticalAlignment: number;
  58698. /** @hidden */
  58699. protected _isDirty: boolean;
  58700. /** @hidden */
  58701. protected _wasDirty: boolean;
  58702. /** @hidden */ private _tempParentMeasure: Measure;
  58703. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  58704. /** @hidden */
  58705. protected _cachedParentMeasure: Measure;
  58706. private _paddingLeft;
  58707. private _paddingRight;
  58708. private _paddingTop;
  58709. private _paddingBottom;
  58710. /** @hidden */ private _left: ValueAndUnit;
  58711. /** @hidden */ private _top: ValueAndUnit;
  58712. private _scaleX;
  58713. private _scaleY;
  58714. private _rotation;
  58715. private _transformCenterX;
  58716. private _transformCenterY;
  58717. /** @hidden */ private _transformMatrix: Matrix2D;
  58718. /** @hidden */
  58719. protected _invertTransformMatrix: Matrix2D;
  58720. /** @hidden */
  58721. protected _transformedPosition: BABYLON.Vector2;
  58722. private _isMatrixDirty;
  58723. private _cachedOffsetX;
  58724. private _cachedOffsetY;
  58725. private _isVisible;
  58726. private _isHighlighted;
  58727. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58728. private _fontSet;
  58729. private _dummyVector2;
  58730. private _downCount;
  58731. private _enterCount;
  58732. private _doNotRender;
  58733. private _downPointerIds;
  58734. protected _isEnabled: boolean;
  58735. protected _disabledColor: string;
  58736. /** @hidden */
  58737. protected _rebuildLayout: boolean;
  58738. /** @hidden */ private _isClipped: boolean;
  58739. /** @hidden */ private _tag: any;
  58740. /**
  58741. * 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
  58742. */
  58743. uniqueId: number;
  58744. /**
  58745. * Gets or sets an object used to store user defined information for the node
  58746. */
  58747. metadata: any;
  58748. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  58749. isHitTestVisible: boolean;
  58750. /** Gets or sets a boolean indicating if the control can block pointer events */
  58751. isPointerBlocker: boolean;
  58752. /** Gets or sets a boolean indicating if the control can be focusable */
  58753. isFocusInvisible: boolean;
  58754. /**
  58755. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  58756. * 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
  58757. */
  58758. clipChildren: boolean;
  58759. /**
  58760. * Gets or sets a boolean indicating that control content must be clipped
  58761. * 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
  58762. */
  58763. clipContent: boolean;
  58764. /**
  58765. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  58766. */
  58767. useBitmapCache: boolean;
  58768. private _cacheData;
  58769. private _shadowOffsetX;
  58770. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  58771. shadowOffsetX: number;
  58772. private _shadowOffsetY;
  58773. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  58774. shadowOffsetY: number;
  58775. private _shadowBlur;
  58776. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  58777. shadowBlur: number;
  58778. private _shadowColor;
  58779. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  58780. shadowColor: string;
  58781. /** Gets or sets the cursor to use when the control is hovered */
  58782. hoverCursor: string;
  58783. /** @hidden */
  58784. protected _linkOffsetX: ValueAndUnit;
  58785. /** @hidden */
  58786. protected _linkOffsetY: ValueAndUnit;
  58787. /** Gets the control type name */
  58788. readonly typeName: string;
  58789. /**
  58790. * Get the current class name of the control.
  58791. * @returns current class name
  58792. */
  58793. getClassName(): string;
  58794. /**
  58795. * An event triggered when the pointer move over the control.
  58796. */
  58797. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  58798. /**
  58799. * An event triggered when the pointer move out of the control.
  58800. */
  58801. onPointerOutObservable: BABYLON.Observable<Control>;
  58802. /**
  58803. * An event triggered when the pointer taps the control
  58804. */
  58805. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  58806. /**
  58807. * An event triggered when pointer up
  58808. */
  58809. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  58810. /**
  58811. * An event triggered when a control is clicked on
  58812. */
  58813. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  58814. /**
  58815. * An event triggered when pointer enters the control
  58816. */
  58817. onPointerEnterObservable: BABYLON.Observable<Control>;
  58818. /**
  58819. * An event triggered when the control is marked as dirty
  58820. */
  58821. onDirtyObservable: BABYLON.Observable<Control>;
  58822. /**
  58823. * An event triggered before drawing the control
  58824. */
  58825. onBeforeDrawObservable: BABYLON.Observable<Control>;
  58826. /**
  58827. * An event triggered after the control was drawn
  58828. */
  58829. onAfterDrawObservable: BABYLON.Observable<Control>;
  58830. /**
  58831. * Get the hosting AdvancedDynamicTexture
  58832. */
  58833. readonly host: AdvancedDynamicTexture;
  58834. /** Gets or set information about font offsets (used to render and align text) */
  58835. fontOffset: {
  58836. ascent: number;
  58837. height: number;
  58838. descent: number;
  58839. };
  58840. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  58841. alpha: number;
  58842. /**
  58843. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  58844. */
  58845. isHighlighted: boolean;
  58846. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  58847. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58848. */
  58849. scaleX: number;
  58850. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  58851. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58852. */
  58853. scaleY: number;
  58854. /** Gets or sets the rotation angle (0 by default)
  58855. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58856. */
  58857. rotation: number;
  58858. /** Gets or sets the transformation center on Y axis (0 by default)
  58859. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58860. */
  58861. transformCenterY: number;
  58862. /** Gets or sets the transformation center on X axis (0 by default)
  58863. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  58864. */
  58865. transformCenterX: number;
  58866. /**
  58867. * Gets or sets the horizontal alignment
  58868. * @see http://doc.babylonjs.com/how_to/gui#alignments
  58869. */
  58870. horizontalAlignment: number;
  58871. /**
  58872. * Gets or sets the vertical alignment
  58873. * @see http://doc.babylonjs.com/how_to/gui#alignments
  58874. */
  58875. verticalAlignment: number;
  58876. /**
  58877. * Gets or sets control width
  58878. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58879. */
  58880. width: string | number;
  58881. /**
  58882. * Gets or sets the control width in pixel
  58883. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58884. */
  58885. widthInPixels: number;
  58886. /**
  58887. * Gets or sets control height
  58888. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58889. */
  58890. height: string | number;
  58891. /**
  58892. * Gets or sets control height in pixel
  58893. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58894. */
  58895. heightInPixels: number;
  58896. /** Gets or set font family */
  58897. fontFamily: string;
  58898. /** Gets or sets font style */
  58899. fontStyle: string;
  58900. /** Gets or sets font weight */
  58901. fontWeight: string;
  58902. /**
  58903. * Gets or sets style
  58904. * @see http://doc.babylonjs.com/how_to/gui#styles
  58905. */
  58906. style: BABYLON.Nullable<Style>;
  58907. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  58908. /** Gets or sets font size in pixels */
  58909. fontSizeInPixels: number;
  58910. /** Gets or sets font size */
  58911. fontSize: string | number;
  58912. /** Gets or sets foreground color */
  58913. color: string;
  58914. /** Gets or sets z index which is used to reorder controls on the z axis */
  58915. zIndex: number;
  58916. /** Gets or sets a boolean indicating if the control can be rendered */
  58917. notRenderable: boolean;
  58918. /** Gets or sets a boolean indicating if the control is visible */
  58919. isVisible: boolean;
  58920. /** Gets a boolean indicating that the control needs to update its rendering */
  58921. readonly isDirty: boolean;
  58922. /**
  58923. * Gets the current linked mesh (or null if none)
  58924. */
  58925. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  58926. /**
  58927. * Gets or sets a value indicating the padding to use on the left of the control
  58928. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58929. */
  58930. paddingLeft: string | number;
  58931. /**
  58932. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  58933. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58934. */
  58935. paddingLeftInPixels: number;
  58936. /**
  58937. * Gets or sets a value indicating the padding to use on the right of the control
  58938. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58939. */
  58940. paddingRight: string | number;
  58941. /**
  58942. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  58943. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58944. */
  58945. paddingRightInPixels: number;
  58946. /**
  58947. * Gets or sets a value indicating the padding to use on the top of the control
  58948. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58949. */
  58950. paddingTop: string | number;
  58951. /**
  58952. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  58953. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58954. */
  58955. paddingTopInPixels: number;
  58956. /**
  58957. * Gets or sets a value indicating the padding to use on the bottom of the control
  58958. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58959. */
  58960. paddingBottom: string | number;
  58961. /**
  58962. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  58963. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58964. */
  58965. paddingBottomInPixels: number;
  58966. /**
  58967. * Gets or sets a value indicating the left coordinate of the control
  58968. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58969. */
  58970. left: string | number;
  58971. /**
  58972. * Gets or sets a value indicating the left coordinate in pixels of the control
  58973. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58974. */
  58975. leftInPixels: number;
  58976. /**
  58977. * Gets or sets a value indicating the top coordinate of the control
  58978. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58979. */
  58980. top: string | number;
  58981. /**
  58982. * Gets or sets a value indicating the top coordinate in pixels of the control
  58983. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  58984. */
  58985. topInPixels: number;
  58986. /**
  58987. * Gets or sets a value indicating the offset on X axis to the linked mesh
  58988. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  58989. */
  58990. linkOffsetX: string | number;
  58991. /**
  58992. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  58993. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  58994. */
  58995. linkOffsetXInPixels: number;
  58996. /**
  58997. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  58998. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  58999. */
  59000. linkOffsetY: string | number;
  59001. /**
  59002. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  59003. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59004. */
  59005. linkOffsetYInPixels: number;
  59006. /** Gets the center coordinate on X axis */
  59007. readonly centerX: number;
  59008. /** Gets the center coordinate on Y axis */
  59009. readonly centerY: number;
  59010. /** Gets or sets if control is Enabled*/
  59011. isEnabled: boolean;
  59012. /** Gets or sets background color of control if it's disabled*/
  59013. disabledColor: string;
  59014. /**
  59015. * Creates a new control
  59016. * @param name defines the name of the control
  59017. */
  59018. constructor(
  59019. /** defines the name of the control */
  59020. name?: string | undefined);
  59021. /** @hidden */
  59022. protected _getTypeName(): string;
  59023. /**
  59024. * Gets the first ascendant in the hierarchy of the given type
  59025. * @param className defines the required type
  59026. * @returns the ascendant or null if not found
  59027. */
  59028. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  59029. /** @hidden */ private _resetFontCache(): void;
  59030. /**
  59031. * Determines if a container is an ascendant of the current control
  59032. * @param container defines the container to look for
  59033. * @returns true if the container is one of the ascendant of the control
  59034. */
  59035. isAscendant(container: Control): boolean;
  59036. /**
  59037. * Gets coordinates in local control space
  59038. * @param globalCoordinates defines the coordinates to transform
  59039. * @returns the new coordinates in local space
  59040. */
  59041. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59042. /**
  59043. * Gets coordinates in local control space
  59044. * @param globalCoordinates defines the coordinates to transform
  59045. * @param result defines the target vector2 where to store the result
  59046. * @returns the current control
  59047. */
  59048. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  59049. /**
  59050. * Gets coordinates in parent local control space
  59051. * @param globalCoordinates defines the coordinates to transform
  59052. * @returns the new coordinates in parent local space
  59053. */
  59054. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  59055. /**
  59056. * Move the current control to a vector3 position projected onto the screen.
  59057. * @param position defines the target position
  59058. * @param scene defines the hosting scene
  59059. */
  59060. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  59061. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  59062. /**
  59063. * Will return all controls that have this control as ascendant
  59064. * @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
  59065. * @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
  59066. * @return all child controls
  59067. */
  59068. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  59069. /**
  59070. * Link current control with a target mesh
  59071. * @param mesh defines the mesh to link with
  59072. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  59073. */
  59074. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  59075. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  59076. /** @hidden */ private _offsetLeft(offset: number): void;
  59077. /** @hidden */ private _offsetTop(offset: number): void;
  59078. /** @hidden */ private _markMatrixAsDirty(): void;
  59079. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  59080. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  59081. /** @hidden */
  59082. protected invalidateRect(): void;
  59083. /** @hidden */ private _markAsDirty(force?: boolean): void;
  59084. /** @hidden */ private _markAllAsDirty(): void;
  59085. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  59086. /** @hidden */
  59087. protected _transform(context?: CanvasRenderingContext2D): void;
  59088. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  59089. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  59090. /** @hidden */
  59091. protected _applyStates(context: CanvasRenderingContext2D): void;
  59092. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  59093. /** @hidden */
  59094. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59095. protected _evaluateClippingState(parentMeasure: Measure): void;
  59096. /** @hidden */ private _measure(): void;
  59097. /** @hidden */
  59098. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59099. /** @hidden */
  59100. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59101. /** @hidden */
  59102. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59103. /** @hidden */
  59104. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  59105. private static _ClipMeasure;
  59106. private _tmpMeasureA;
  59107. private _clip;
  59108. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  59109. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  59110. /**
  59111. * Tests if a given coordinates belong to the current control
  59112. * @param x defines x coordinate to test
  59113. * @param y defines y coordinate to test
  59114. * @returns true if the coordinates are inside the control
  59115. */
  59116. contains(x: number, y: number): boolean;
  59117. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  59118. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  59119. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  59120. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  59121. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  59122. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59123. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  59124. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  59125. private _prepareFont;
  59126. /** Releases associated resources */
  59127. dispose(): void;
  59128. private static _HORIZONTAL_ALIGNMENT_LEFT;
  59129. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  59130. private static _HORIZONTAL_ALIGNMENT_CENTER;
  59131. private static _VERTICAL_ALIGNMENT_TOP;
  59132. private static _VERTICAL_ALIGNMENT_BOTTOM;
  59133. private static _VERTICAL_ALIGNMENT_CENTER;
  59134. /** HORIZONTAL_ALIGNMENT_LEFT */
  59135. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  59136. /** HORIZONTAL_ALIGNMENT_RIGHT */
  59137. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  59138. /** HORIZONTAL_ALIGNMENT_CENTER */
  59139. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  59140. /** VERTICAL_ALIGNMENT_TOP */
  59141. static readonly VERTICAL_ALIGNMENT_TOP: number;
  59142. /** VERTICAL_ALIGNMENT_BOTTOM */
  59143. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  59144. /** VERTICAL_ALIGNMENT_CENTER */
  59145. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  59146. private static _FontHeightSizes;
  59147. /** @hidden */ private static _GetFontOffset(font: string): {
  59148. ascent: number;
  59149. height: number;
  59150. descent: number;
  59151. };
  59152. /**
  59153. * Creates a stack panel that can be used to render headers
  59154. * @param control defines the control to associate with the header
  59155. * @param text defines the text of the header
  59156. * @param size defines the size of the header
  59157. * @param options defines options used to configure the header
  59158. * @returns a new StackPanel
  59159. * @ignore
  59160. * @hidden
  59161. */
  59162. static AddHeader: (control: Control, text: string, size: string | number, options: {
  59163. isHorizontal: boolean;
  59164. controlFirst: boolean;
  59165. }) => any;
  59166. /** @hidden */
  59167. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  59168. }
  59169. }
  59170. declare module BABYLON.GUI {
  59171. /**
  59172. * Root class for 2D containers
  59173. * @see http://doc.babylonjs.com/how_to/gui#containers
  59174. */
  59175. export class Container extends Control {
  59176. name?: string | undefined;
  59177. /** @hidden */
  59178. protected _children: Control[];
  59179. /** @hidden */
  59180. protected _measureForChildren: Measure;
  59181. /** @hidden */
  59182. protected _background: string;
  59183. /** @hidden */
  59184. protected _adaptWidthToChildren: boolean;
  59185. /** @hidden */
  59186. protected _adaptHeightToChildren: boolean;
  59187. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  59188. adaptHeightToChildren: boolean;
  59189. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  59190. adaptWidthToChildren: boolean;
  59191. /** Gets or sets background color */
  59192. background: string;
  59193. /** Gets the list of children */
  59194. readonly children: Control[];
  59195. /**
  59196. * Creates a new Container
  59197. * @param name defines the name of the container
  59198. */
  59199. constructor(name?: string | undefined);
  59200. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  59201. /**
  59202. * Gets a child using its name
  59203. * @param name defines the child name to look for
  59204. * @returns the child control if found
  59205. */
  59206. getChildByName(name: string): BABYLON.Nullable<Control>;
  59207. /**
  59208. * Gets a child using its type and its name
  59209. * @param name defines the child name to look for
  59210. * @param type defines the child type to look for
  59211. * @returns the child control if found
  59212. */
  59213. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  59214. /**
  59215. * Search for a specific control in children
  59216. * @param control defines the control to look for
  59217. * @returns true if the control is in child list
  59218. */
  59219. containsControl(control: Control): boolean;
  59220. /**
  59221. * Adds a new control to the current container
  59222. * @param control defines the control to add
  59223. * @returns the current container
  59224. */
  59225. addControl(control: BABYLON.Nullable<Control>): Container;
  59226. /**
  59227. * Removes all controls from the current container
  59228. * @returns the current container
  59229. */
  59230. clearControls(): Container;
  59231. /**
  59232. * Removes a control from the current container
  59233. * @param control defines the control to remove
  59234. * @returns the current container
  59235. */
  59236. removeControl(control: Control): Container;
  59237. /** @hidden */ private _reOrderControl(control: Control): void;
  59238. /** @hidden */ private _offsetLeft(offset: number): void;
  59239. /** @hidden */ private _offsetTop(offset: number): void;
  59240. /** @hidden */ private _markAllAsDirty(): void;
  59241. /** @hidden */
  59242. protected _localDraw(context: CanvasRenderingContext2D): void;
  59243. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  59244. /** @hidden */
  59245. protected _beforeLayout(): void;
  59246. /** @hidden */
  59247. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59248. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  59249. protected _postMeasure(): void;
  59250. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  59251. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  59252. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  59253. /** @hidden */
  59254. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59255. /** Releases associated resources */
  59256. dispose(): void;
  59257. }
  59258. }
  59259. declare module BABYLON.GUI {
  59260. /** Class used to create rectangle container */
  59261. export class Rectangle extends Container {
  59262. name?: string | undefined;
  59263. private _thickness;
  59264. private _cornerRadius;
  59265. /** Gets or sets border thickness */
  59266. thickness: number;
  59267. /** Gets or sets the corner radius angle */
  59268. cornerRadius: number;
  59269. /**
  59270. * Creates a new Rectangle
  59271. * @param name defines the control name
  59272. */
  59273. constructor(name?: string | undefined);
  59274. protected _getTypeName(): string;
  59275. protected _localDraw(context: CanvasRenderingContext2D): void;
  59276. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59277. private _drawRoundedRect;
  59278. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  59279. }
  59280. }
  59281. declare module BABYLON.GUI {
  59282. /**
  59283. * Enum that determines the text-wrapping mode to use.
  59284. */
  59285. export enum TextWrapping {
  59286. /**
  59287. * Clip the text when it's larger than Control.width; this is the default mode.
  59288. */
  59289. Clip = 0,
  59290. /**
  59291. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  59292. */
  59293. WordWrap = 1,
  59294. /**
  59295. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  59296. */
  59297. Ellipsis = 2
  59298. }
  59299. /**
  59300. * Class used to create text block control
  59301. */
  59302. export class TextBlock extends Control {
  59303. /**
  59304. * Defines the name of the control
  59305. */
  59306. name?: string | undefined;
  59307. private _text;
  59308. private _textWrapping;
  59309. private _textHorizontalAlignment;
  59310. private _textVerticalAlignment;
  59311. private _lines;
  59312. private _resizeToFit;
  59313. private _lineSpacing;
  59314. private _outlineWidth;
  59315. private _outlineColor;
  59316. /**
  59317. * An event triggered after the text is changed
  59318. */
  59319. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  59320. /**
  59321. * An event triggered after the text was broken up into lines
  59322. */
  59323. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  59324. /**
  59325. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  59326. */
  59327. readonly lines: any[];
  59328. /**
  59329. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  59330. */
  59331. /**
  59332. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  59333. */
  59334. resizeToFit: boolean;
  59335. /**
  59336. * Gets or sets a boolean indicating if text must be wrapped
  59337. */
  59338. /**
  59339. * Gets or sets a boolean indicating if text must be wrapped
  59340. */
  59341. textWrapping: TextWrapping | boolean;
  59342. /**
  59343. * Gets or sets text to display
  59344. */
  59345. /**
  59346. * Gets or sets text to display
  59347. */
  59348. text: string;
  59349. /**
  59350. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  59351. */
  59352. /**
  59353. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  59354. */
  59355. textHorizontalAlignment: number;
  59356. /**
  59357. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  59358. */
  59359. /**
  59360. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  59361. */
  59362. textVerticalAlignment: number;
  59363. /**
  59364. * Gets or sets line spacing value
  59365. */
  59366. /**
  59367. * Gets or sets line spacing value
  59368. */
  59369. lineSpacing: string | number;
  59370. /**
  59371. * Gets or sets outlineWidth of the text to display
  59372. */
  59373. /**
  59374. * Gets or sets outlineWidth of the text to display
  59375. */
  59376. outlineWidth: number;
  59377. /**
  59378. * Gets or sets outlineColor of the text to display
  59379. */
  59380. /**
  59381. * Gets or sets outlineColor of the text to display
  59382. */
  59383. outlineColor: string;
  59384. /**
  59385. * Creates a new TextBlock object
  59386. * @param name defines the name of the control
  59387. * @param text defines the text to display (emptry string by default)
  59388. */
  59389. constructor(
  59390. /**
  59391. * Defines the name of the control
  59392. */
  59393. name?: string | undefined, text?: string);
  59394. protected _getTypeName(): string;
  59395. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59396. private _drawText;
  59397. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  59398. protected _applyStates(context: CanvasRenderingContext2D): void;
  59399. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  59400. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  59401. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  59402. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  59403. protected _renderLines(context: CanvasRenderingContext2D): void;
  59404. /**
  59405. * Given a width constraint applied on the text block, find the expected height
  59406. * @returns expected height
  59407. */
  59408. computeExpectedHeight(): number;
  59409. dispose(): void;
  59410. }
  59411. }
  59412. declare module BABYLON.GUI {
  59413. /**
  59414. * Class used to create 2D images
  59415. */
  59416. export class Image extends Control {
  59417. name?: string | undefined;
  59418. private static _WorkingCanvas;
  59419. private _domImage;
  59420. private _imageWidth;
  59421. private _imageHeight;
  59422. private _loaded;
  59423. private _stretch;
  59424. private _source;
  59425. private _autoScale;
  59426. private _sourceLeft;
  59427. private _sourceTop;
  59428. private _sourceWidth;
  59429. private _sourceHeight;
  59430. private _cellWidth;
  59431. private _cellHeight;
  59432. private _cellId;
  59433. private _populateNinePatchSlicesFromImage;
  59434. private _sliceLeft;
  59435. private _sliceRight;
  59436. private _sliceTop;
  59437. private _sliceBottom;
  59438. private _detectPointerOnOpaqueOnly;
  59439. /**
  59440. * BABYLON.Observable notified when the content is loaded
  59441. */
  59442. onImageLoadedObservable: BABYLON.Observable<Image>;
  59443. /**
  59444. * Gets a boolean indicating that the content is loaded
  59445. */
  59446. readonly isLoaded: boolean;
  59447. /**
  59448. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  59449. */
  59450. populateNinePatchSlicesFromImage: boolean;
  59451. /**
  59452. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  59453. * Beware using this as this will comsume more memory as the image has to be stored twice
  59454. */
  59455. detectPointerOnOpaqueOnly: boolean;
  59456. /**
  59457. * Gets or sets the left value for slicing (9-patch)
  59458. */
  59459. sliceLeft: number;
  59460. /**
  59461. * Gets or sets the right value for slicing (9-patch)
  59462. */
  59463. sliceRight: number;
  59464. /**
  59465. * Gets or sets the top value for slicing (9-patch)
  59466. */
  59467. sliceTop: number;
  59468. /**
  59469. * Gets or sets the bottom value for slicing (9-patch)
  59470. */
  59471. sliceBottom: number;
  59472. /**
  59473. * Gets or sets the left coordinate in the source image
  59474. */
  59475. sourceLeft: number;
  59476. /**
  59477. * Gets or sets the top coordinate in the source image
  59478. */
  59479. sourceTop: number;
  59480. /**
  59481. * Gets or sets the width to capture in the source image
  59482. */
  59483. sourceWidth: number;
  59484. /**
  59485. * Gets or sets the height to capture in the source image
  59486. */
  59487. sourceHeight: number;
  59488. /**
  59489. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  59490. * @see http://doc.babylonjs.com/how_to/gui#image
  59491. */
  59492. autoScale: boolean;
  59493. /** Gets or sets the streching mode used by the image */
  59494. stretch: number;
  59495. /**
  59496. * Gets or sets the internal DOM image used to render the control
  59497. */
  59498. domImage: HTMLImageElement;
  59499. private _onImageLoaded;
  59500. private _extractNinePatchSliceDataFromImage;
  59501. /**
  59502. * Gets or sets image source url
  59503. */
  59504. source: BABYLON.Nullable<string>;
  59505. /**
  59506. * Gets or sets the cell width to use when animation sheet is enabled
  59507. * @see http://doc.babylonjs.com/how_to/gui#image
  59508. */
  59509. cellWidth: number;
  59510. /**
  59511. * Gets or sets the cell height to use when animation sheet is enabled
  59512. * @see http://doc.babylonjs.com/how_to/gui#image
  59513. */
  59514. cellHeight: number;
  59515. /**
  59516. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  59517. * @see http://doc.babylonjs.com/how_to/gui#image
  59518. */
  59519. cellId: number;
  59520. /**
  59521. * Creates a new Image
  59522. * @param name defines the control name
  59523. * @param url defines the image url
  59524. */
  59525. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  59526. /**
  59527. * Tests if a given coordinates belong to the current control
  59528. * @param x defines x coordinate to test
  59529. * @param y defines y coordinate to test
  59530. * @returns true if the coordinates are inside the control
  59531. */
  59532. contains(x: number, y: number): boolean;
  59533. protected _getTypeName(): string;
  59534. /** Force the control to synchronize with its content */
  59535. synchronizeSizeWithContent(): void;
  59536. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59537. private _prepareWorkingCanvasForOpaqueDetection;
  59538. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  59539. private _renderCornerPatch;
  59540. private _renderNinePatch;
  59541. dispose(): void;
  59542. /** STRETCH_NONE */
  59543. static readonly STRETCH_NONE: number;
  59544. /** STRETCH_FILL */
  59545. static readonly STRETCH_FILL: number;
  59546. /** STRETCH_UNIFORM */
  59547. static readonly STRETCH_UNIFORM: number;
  59548. /** STRETCH_EXTEND */
  59549. static readonly STRETCH_EXTEND: number;
  59550. /** NINE_PATCH */
  59551. static readonly STRETCH_NINE_PATCH: number;
  59552. }
  59553. }
  59554. declare module BABYLON.GUI {
  59555. /**
  59556. * Class used to create 2D buttons
  59557. */
  59558. export class Button extends Rectangle {
  59559. name?: string | undefined;
  59560. /**
  59561. * Function called to generate a pointer enter animation
  59562. */
  59563. pointerEnterAnimation: () => void;
  59564. /**
  59565. * Function called to generate a pointer out animation
  59566. */
  59567. pointerOutAnimation: () => void;
  59568. /**
  59569. * Function called to generate a pointer down animation
  59570. */
  59571. pointerDownAnimation: () => void;
  59572. /**
  59573. * Function called to generate a pointer up animation
  59574. */
  59575. pointerUpAnimation: () => void;
  59576. private _image;
  59577. /**
  59578. * Returns the image part of the button (if any)
  59579. */
  59580. readonly image: BABYLON.Nullable<Image>;
  59581. private _textBlock;
  59582. /**
  59583. * Returns the image part of the button (if any)
  59584. */
  59585. readonly textBlock: BABYLON.Nullable<TextBlock>;
  59586. /**
  59587. * Creates a new Button
  59588. * @param name defines the name of the button
  59589. */
  59590. constructor(name?: string | undefined);
  59591. protected _getTypeName(): string;
  59592. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  59593. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  59594. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  59595. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  59596. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59597. /**
  59598. * Creates a new button made with an image and a text
  59599. * @param name defines the name of the button
  59600. * @param text defines the text of the button
  59601. * @param imageUrl defines the url of the image
  59602. * @returns a new Button
  59603. */
  59604. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  59605. /**
  59606. * Creates a new button made with an image
  59607. * @param name defines the name of the button
  59608. * @param imageUrl defines the url of the image
  59609. * @returns a new Button
  59610. */
  59611. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  59612. /**
  59613. * Creates a new button made with a text
  59614. * @param name defines the name of the button
  59615. * @param text defines the text of the button
  59616. * @returns a new Button
  59617. */
  59618. static CreateSimpleButton(name: string, text: string): Button;
  59619. /**
  59620. * Creates a new button made with an image and a centered text
  59621. * @param name defines the name of the button
  59622. * @param text defines the text of the button
  59623. * @param imageUrl defines the url of the image
  59624. * @returns a new Button
  59625. */
  59626. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  59627. }
  59628. }
  59629. declare module BABYLON.GUI {
  59630. /**
  59631. * Class used to create a 2D stack panel container
  59632. */
  59633. export class StackPanel extends Container {
  59634. name?: string | undefined;
  59635. private _isVertical;
  59636. private _manualWidth;
  59637. private _manualHeight;
  59638. private _doNotTrackManualChanges;
  59639. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  59640. isVertical: boolean;
  59641. /**
  59642. * Gets or sets panel width.
  59643. * This value should not be set when in horizontal mode as it will be computed automatically
  59644. */
  59645. width: string | number;
  59646. /**
  59647. * Gets or sets panel height.
  59648. * This value should not be set when in vertical mode as it will be computed automatically
  59649. */
  59650. height: string | number;
  59651. /**
  59652. * Creates a new StackPanel
  59653. * @param name defines control name
  59654. */
  59655. constructor(name?: string | undefined);
  59656. protected _getTypeName(): string;
  59657. /** @hidden */
  59658. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59659. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  59660. protected _postMeasure(): void;
  59661. }
  59662. }
  59663. declare module BABYLON.GUI {
  59664. /**
  59665. * Class used to represent a 2D checkbox
  59666. */
  59667. export class Checkbox extends Control {
  59668. name?: string | undefined;
  59669. private _isChecked;
  59670. private _background;
  59671. private _checkSizeRatio;
  59672. private _thickness;
  59673. /** Gets or sets border thickness */
  59674. thickness: number;
  59675. /**
  59676. * BABYLON.Observable raised when isChecked property changes
  59677. */
  59678. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  59679. /** Gets or sets a value indicating the ratio between overall size and check size */
  59680. checkSizeRatio: number;
  59681. /** Gets or sets background color */
  59682. background: string;
  59683. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  59684. isChecked: boolean;
  59685. /**
  59686. * Creates a new CheckBox
  59687. * @param name defines the control name
  59688. */
  59689. constructor(name?: string | undefined);
  59690. protected _getTypeName(): string;
  59691. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  59692. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  59693. /**
  59694. * Utility function to easily create a checkbox with a header
  59695. * @param title defines the label to use for the header
  59696. * @param onValueChanged defines the callback to call when value changes
  59697. * @returns a StackPanel containing the checkbox and a textBlock
  59698. */
  59699. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  59700. }
  59701. }
  59702. declare module BABYLON.GUI {
  59703. /**
  59704. * Class used to store key control properties
  59705. */
  59706. export class KeyPropertySet {
  59707. /** Width */
  59708. width?: string;
  59709. /** Height */
  59710. height?: string;
  59711. /** Left padding */
  59712. paddingLeft?: string;
  59713. /** Right padding */
  59714. paddingRight?: string;
  59715. /** Top padding */
  59716. paddingTop?: string;
  59717. /** Bottom padding */
  59718. paddingBottom?: string;
  59719. /** Foreground color */
  59720. color?: string;
  59721. /** Background color */
  59722. background?: string;
  59723. }
  59724. /**
  59725. * Class used to create virtual keyboard
  59726. */
  59727. export class VirtualKeyboard extends StackPanel {
  59728. /** BABYLON.Observable raised when a key is pressed */
  59729. onKeyPressObservable: BABYLON.Observable<string>;
  59730. /** Gets or sets default key button width */
  59731. defaultButtonWidth: string;
  59732. /** Gets or sets default key button height */
  59733. defaultButtonHeight: string;
  59734. /** Gets or sets default key button left padding */
  59735. defaultButtonPaddingLeft: string;
  59736. /** Gets or sets default key button right padding */
  59737. defaultButtonPaddingRight: string;
  59738. /** Gets or sets default key button top padding */
  59739. defaultButtonPaddingTop: string;
  59740. /** Gets or sets default key button bottom padding */
  59741. defaultButtonPaddingBottom: string;
  59742. /** Gets or sets default key button foreground color */
  59743. defaultButtonColor: string;
  59744. /** Gets or sets default key button background color */
  59745. defaultButtonBackground: string;
  59746. /** Gets or sets shift button foreground color */
  59747. shiftButtonColor: string;
  59748. /** Gets or sets shift button thickness*/
  59749. selectedShiftThickness: number;
  59750. /** Gets shift key state */
  59751. shiftState: number;
  59752. protected _getTypeName(): string;
  59753. private _createKey;
  59754. /**
  59755. * Adds a new row of keys
  59756. * @param keys defines the list of keys to add
  59757. * @param propertySets defines the associated property sets
  59758. */
  59759. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  59760. /**
  59761. * Set the shift key to a specific state
  59762. * @param shiftState defines the new shift state
  59763. */
  59764. applyShiftState(shiftState: number): void;
  59765. private _currentlyConnectedInputText;
  59766. private _connectedInputTexts;
  59767. private _onKeyPressObserver;
  59768. /** Gets the input text control currently attached to the keyboard */
  59769. readonly connectedInputText: BABYLON.Nullable<InputText>;
  59770. /**
  59771. * Connects the keyboard with an input text control
  59772. *
  59773. * @param input defines the target control
  59774. */
  59775. connect(input: InputText): void;
  59776. /**
  59777. * Disconnects the keyboard from connected InputText controls
  59778. *
  59779. * @param input optionally defines a target control, otherwise all are disconnected
  59780. */
  59781. disconnect(input?: InputText): void;
  59782. private _removeConnectedInputObservables;
  59783. /**
  59784. * Release all resources
  59785. */
  59786. dispose(): void;
  59787. /**
  59788. * Creates a new keyboard using a default layout
  59789. *
  59790. * @param name defines control name
  59791. * @returns a new VirtualKeyboard
  59792. */
  59793. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  59794. }
  59795. }
  59796. declare module BABYLON.GUI {
  59797. /**
  59798. * Class used to create input text control
  59799. */
  59800. export class InputText extends Control implements IFocusableControl {
  59801. name?: string | undefined;
  59802. private _text;
  59803. private _placeholderText;
  59804. private _background;
  59805. private _focusedBackground;
  59806. private _focusedColor;
  59807. private _placeholderColor;
  59808. private _thickness;
  59809. private _margin;
  59810. private _autoStretchWidth;
  59811. private _maxWidth;
  59812. private _isFocused;
  59813. private _blinkTimeout;
  59814. private _blinkIsEven;
  59815. private _cursorOffset;
  59816. private _scrollLeft;
  59817. private _textWidth;
  59818. private _clickedCoordinate;
  59819. private _deadKey;
  59820. private _addKey;
  59821. private _currentKey;
  59822. private _isTextHighlightOn;
  59823. private _textHighlightColor;
  59824. private _highligherOpacity;
  59825. private _highlightedText;
  59826. private _startHighlightIndex;
  59827. private _endHighlightIndex;
  59828. private _cursorIndex;
  59829. private _onFocusSelectAll;
  59830. private _isPointerDown;
  59831. private _onClipboardObserver;
  59832. private _onPointerDblTapObserver;
  59833. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  59834. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  59835. promptMessage: string;
  59836. /** BABYLON.Observable raised when the text changes */
  59837. onTextChangedObservable: BABYLON.Observable<InputText>;
  59838. /** BABYLON.Observable raised just before an entered character is to be added */
  59839. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  59840. /** BABYLON.Observable raised when the control gets the focus */
  59841. onFocusObservable: BABYLON.Observable<InputText>;
  59842. /** BABYLON.Observable raised when the control loses the focus */
  59843. onBlurObservable: BABYLON.Observable<InputText>;
  59844. /**Observable raised when the text is highlighted */
  59845. onTextHighlightObservable: BABYLON.Observable<InputText>;
  59846. /**Observable raised when copy event is triggered */
  59847. onTextCopyObservable: BABYLON.Observable<InputText>;
  59848. /** BABYLON.Observable raised when cut event is triggered */
  59849. onTextCutObservable: BABYLON.Observable<InputText>;
  59850. /** BABYLON.Observable raised when paste event is triggered */
  59851. onTextPasteObservable: BABYLON.Observable<InputText>;
  59852. /** BABYLON.Observable raised when a key event was processed */
  59853. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  59854. /** Gets or sets the maximum width allowed by the control */
  59855. maxWidth: string | number;
  59856. /** Gets the maximum width allowed by the control in pixels */
  59857. readonly maxWidthInPixels: number;
  59858. /** Gets or sets the text highlighter transparency; default: 0.4 */
  59859. highligherOpacity: number;
  59860. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  59861. onFocusSelectAll: boolean;
  59862. /** Gets or sets the text hightlight color */
  59863. textHighlightColor: string;
  59864. /** Gets or sets control margin */
  59865. margin: string;
  59866. /** Gets control margin in pixels */
  59867. readonly marginInPixels: number;
  59868. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  59869. autoStretchWidth: boolean;
  59870. /** Gets or sets border thickness */
  59871. thickness: number;
  59872. /** Gets or sets the background color when focused */
  59873. focusedBackground: string;
  59874. /** Gets or sets the background color when focused */
  59875. focusedColor: string;
  59876. /** Gets or sets the background color */
  59877. background: string;
  59878. /** Gets or sets the placeholder color */
  59879. placeholderColor: string;
  59880. /** Gets or sets the text displayed when the control is empty */
  59881. placeholderText: string;
  59882. /** Gets or sets the dead key flag */
  59883. deadKey: boolean;
  59884. /** Gets or sets the highlight text */
  59885. highlightedText: string;
  59886. /** Gets or sets if the current key should be added */
  59887. addKey: boolean;
  59888. /** Gets or sets the value of the current key being entered */
  59889. currentKey: string;
  59890. /** Gets or sets the text displayed in the control */
  59891. text: string;
  59892. /** Gets or sets control width */
  59893. width: string | number;
  59894. /**
  59895. * Creates a new InputText
  59896. * @param name defines the control name
  59897. * @param text defines the text of the control
  59898. */
  59899. constructor(name?: string | undefined, text?: string);
  59900. /** @hidden */
  59901. onBlur(): void;
  59902. /** @hidden */
  59903. onFocus(): void;
  59904. protected _getTypeName(): string;
  59905. /**
  59906. * Function called to get the list of controls that should not steal the focus from this control
  59907. * @returns an array of controls
  59908. */
  59909. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  59910. /** @hidden */
  59911. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  59912. /** @hidden */
  59913. private _updateValueFromCursorIndex;
  59914. /** @hidden */
  59915. private _processDblClick;
  59916. /** @hidden */
  59917. private _selectAllText;
  59918. /**
  59919. * Handles the keyboard event
  59920. * @param evt Defines the KeyboardEvent
  59921. */
  59922. processKeyboard(evt: KeyboardEvent): void;
  59923. /** @hidden */
  59924. private _onCopyText;
  59925. /** @hidden */
  59926. private _onCutText;
  59927. /** @hidden */
  59928. private _onPasteText; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  59929. protected _beforeRenderText(text: string): string;
  59930. dispose(): void;
  59931. }
  59932. }
  59933. declare module BABYLON.GUI {
  59934. /**
  59935. * Class used to create a 2D grid container
  59936. */
  59937. export class Grid extends Container {
  59938. name?: string | undefined;
  59939. private _rowDefinitions;
  59940. private _columnDefinitions;
  59941. private _cells;
  59942. private _childControls;
  59943. /**
  59944. * Gets the number of columns
  59945. */
  59946. readonly columnCount: number;
  59947. /**
  59948. * Gets the number of rows
  59949. */
  59950. readonly rowCount: number;
  59951. /** Gets the list of children */
  59952. readonly children: Control[];
  59953. /** Gets the list of cells (e.g. the containers) */
  59954. readonly cells: {
  59955. [key: string]: Container;
  59956. };
  59957. /**
  59958. * Gets the definition of a specific row
  59959. * @param index defines the index of the row
  59960. * @returns the row definition
  59961. */
  59962. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  59963. /**
  59964. * Gets the definition of a specific column
  59965. * @param index defines the index of the column
  59966. * @returns the column definition
  59967. */
  59968. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  59969. /**
  59970. * Adds a new row to the grid
  59971. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  59972. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  59973. * @returns the current grid
  59974. */
  59975. addRowDefinition(height: number, isPixel?: boolean): Grid;
  59976. /**
  59977. * Adds a new column to the grid
  59978. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  59979. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  59980. * @returns the current grid
  59981. */
  59982. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  59983. /**
  59984. * Update a row definition
  59985. * @param index defines the index of the row to update
  59986. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  59987. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  59988. * @returns the current grid
  59989. */
  59990. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  59991. /**
  59992. * Update a column definition
  59993. * @param index defines the index of the column to update
  59994. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  59995. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  59996. * @returns the current grid
  59997. */
  59998. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  59999. /**
  60000. * Gets the list of children stored in a specific cell
  60001. * @param row defines the row to check
  60002. * @param column defines the column to check
  60003. * @returns the list of controls
  60004. */
  60005. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  60006. /**
  60007. * Gets a string representing the child cell info (row x column)
  60008. * @param child defines the control to get info from
  60009. * @returns a string containing the child cell info (row x column)
  60010. */
  60011. getChildCellInfo(child: Control): string;
  60012. private _removeCell;
  60013. private _offsetCell;
  60014. /**
  60015. * Remove a column definition at specified index
  60016. * @param index defines the index of the column to remove
  60017. * @returns the current grid
  60018. */
  60019. removeColumnDefinition(index: number): Grid;
  60020. /**
  60021. * Remove a row definition at specified index
  60022. * @param index defines the index of the row to remove
  60023. * @returns the current grid
  60024. */
  60025. removeRowDefinition(index: number): Grid;
  60026. /**
  60027. * Adds a new control to the current grid
  60028. * @param control defines the control to add
  60029. * @param row defines the row where to add the control (0 by default)
  60030. * @param column defines the column where to add the control (0 by default)
  60031. * @returns the current grid
  60032. */
  60033. addControl(control: Control, row?: number, column?: number): Grid;
  60034. /**
  60035. * Removes a control from the current container
  60036. * @param control defines the control to remove
  60037. * @returns the current container
  60038. */
  60039. removeControl(control: Control): Container;
  60040. /**
  60041. * Creates a new Grid
  60042. * @param name defines control name
  60043. */
  60044. constructor(name?: string | undefined);
  60045. protected _getTypeName(): string;
  60046. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  60047. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60048. /** Releases associated resources */
  60049. dispose(): void;
  60050. }
  60051. }
  60052. declare module BABYLON.GUI {
  60053. /** Class used to create color pickers */
  60054. export class ColorPicker extends Control {
  60055. name?: string | undefined;
  60056. private static _Epsilon;
  60057. private _colorWheelCanvas;
  60058. private _value;
  60059. private _tmpColor;
  60060. private _pointerStartedOnSquare;
  60061. private _pointerStartedOnWheel;
  60062. private _squareLeft;
  60063. private _squareTop;
  60064. private _squareSize;
  60065. private _h;
  60066. private _s;
  60067. private _v;
  60068. private _lastPointerDownID;
  60069. /**
  60070. * BABYLON.Observable raised when the value changes
  60071. */
  60072. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  60073. /** Gets or sets the color of the color picker */
  60074. value: BABYLON.Color3;
  60075. /**
  60076. * Gets or sets control width
  60077. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60078. */
  60079. width: string | number;
  60080. /**
  60081. * Gets or sets control height
  60082. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  60083. */
  60084. /** Gets or sets control height */
  60085. height: string | number;
  60086. /** Gets or sets control size */
  60087. size: string | number;
  60088. /**
  60089. * Creates a new ColorPicker
  60090. * @param name defines the control name
  60091. */
  60092. constructor(name?: string | undefined);
  60093. protected _getTypeName(): string;
  60094. /** @hidden */
  60095. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60096. private _updateSquareProps;
  60097. private _drawGradientSquare;
  60098. private _drawCircle;
  60099. private _createColorWheelCanvas;
  60100. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  60101. private _pointerIsDown;
  60102. private _updateValueFromPointer;
  60103. private _isPointOnSquare;
  60104. private _isPointOnWheel; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60105. /**
  60106. * This function expands the color picker by creating a color picker dialog with manual
  60107. * color value input and the ability to save colors into an array to be used later in
  60108. * subsequent launches of the dialogue.
  60109. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  60110. * @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.
  60111. * @returns picked color as a hex string and the saved colors array as hex strings.
  60112. */
  60113. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  60114. pickerWidth?: string;
  60115. pickerHeight?: string;
  60116. headerHeight?: string;
  60117. lastColor?: string;
  60118. swatchLimit?: number;
  60119. numSwatchesPerLine?: number;
  60120. savedColors?: Array<string>;
  60121. }): Promise<{
  60122. savedColors?: string[];
  60123. pickedColor: string;
  60124. }>;
  60125. }
  60126. }
  60127. declare module BABYLON.GUI {
  60128. /** Class used to create 2D ellipse containers */
  60129. export class Ellipse extends Container {
  60130. name?: string | undefined;
  60131. private _thickness;
  60132. /** Gets or sets border thickness */
  60133. thickness: number;
  60134. /**
  60135. * Creates a new Ellipse
  60136. * @param name defines the control name
  60137. */
  60138. constructor(name?: string | undefined);
  60139. protected _getTypeName(): string;
  60140. protected _localDraw(context: CanvasRenderingContext2D): void;
  60141. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60142. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  60143. }
  60144. }
  60145. declare module BABYLON.GUI {
  60146. /**
  60147. * Class used to create a password control
  60148. */
  60149. export class InputPassword extends InputText {
  60150. protected _beforeRenderText(text: string): string;
  60151. }
  60152. }
  60153. declare module BABYLON.GUI {
  60154. /** Class used to render 2D lines */
  60155. export class Line extends Control {
  60156. name?: string | undefined;
  60157. private _lineWidth;
  60158. private _x1;
  60159. private _y1;
  60160. private _x2;
  60161. private _y2;
  60162. private _dash;
  60163. private _connectedControl;
  60164. private _connectedControlDirtyObserver;
  60165. /** Gets or sets the dash pattern */
  60166. dash: Array<number>;
  60167. /** Gets or sets the control connected with the line end */
  60168. connectedControl: Control;
  60169. /** Gets or sets start coordinates on X axis */
  60170. x1: string | number;
  60171. /** Gets or sets start coordinates on Y axis */
  60172. y1: string | number;
  60173. /** Gets or sets end coordinates on X axis */
  60174. x2: string | number;
  60175. /** Gets or sets end coordinates on Y axis */
  60176. y2: string | number;
  60177. /** Gets or sets line width */
  60178. lineWidth: number;
  60179. /** Gets or sets horizontal alignment */
  60180. horizontalAlignment: number;
  60181. /** Gets or sets vertical alignment */
  60182. verticalAlignment: number;
  60183. private readonly _effectiveX2;
  60184. private readonly _effectiveY2;
  60185. /**
  60186. * Creates a new Line
  60187. * @param name defines the control name
  60188. */
  60189. constructor(name?: string | undefined);
  60190. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  60191. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60192. /**
  60193. * Move one end of the line given 3D cartesian coordinates.
  60194. * @param position Targeted world position
  60195. * @param scene BABYLON.Scene
  60196. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  60197. */
  60198. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  60199. /**
  60200. * Move one end of the line to a position in screen absolute space.
  60201. * @param projectedPosition Position in screen absolute space (X, Y)
  60202. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  60203. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  60204. }
  60205. }
  60206. declare module BABYLON.GUI {
  60207. /**
  60208. * Class used to store a point for a MultiLine object.
  60209. * The point can be pure 2D coordinates, a mesh or a control
  60210. */
  60211. export class MultiLinePoint {
  60212. private _multiLine;
  60213. private _x;
  60214. private _y;
  60215. private _control;
  60216. private _mesh;
  60217. private _controlObserver;
  60218. private _meshObserver;
  60219. /** @hidden */ private _point: BABYLON.Vector2;
  60220. /**
  60221. * Creates a new MultiLinePoint
  60222. * @param multiLine defines the source MultiLine object
  60223. */
  60224. constructor(multiLine: MultiLine);
  60225. /** Gets or sets x coordinate */
  60226. x: string | number;
  60227. /** Gets or sets y coordinate */
  60228. y: string | number;
  60229. /** Gets or sets the control associated with this point */
  60230. control: BABYLON.Nullable<Control>;
  60231. /** Gets or sets the mesh associated with this point */
  60232. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  60233. /** Resets links */
  60234. resetLinks(): void;
  60235. /**
  60236. * Gets a translation vector
  60237. * @returns the translation vector
  60238. */
  60239. translate(): BABYLON.Vector2;
  60240. private _translatePoint;
  60241. /** Release associated resources */
  60242. dispose(): void;
  60243. }
  60244. }
  60245. declare module BABYLON.GUI {
  60246. /**
  60247. * Class used to create multi line control
  60248. */
  60249. export class MultiLine extends Control {
  60250. name?: string | undefined;
  60251. private _lineWidth;
  60252. private _dash;
  60253. private _points;
  60254. private _minX;
  60255. private _minY;
  60256. private _maxX;
  60257. private _maxY;
  60258. /**
  60259. * Creates a new MultiLine
  60260. * @param name defines the control name
  60261. */
  60262. constructor(name?: string | undefined);
  60263. /** Gets or sets dash pattern */
  60264. dash: Array<number>;
  60265. /**
  60266. * Gets point stored at specified index
  60267. * @param index defines the index to look for
  60268. * @returns the requested point if found
  60269. */
  60270. getAt(index: number): MultiLinePoint;
  60271. /** Function called when a point is updated */
  60272. onPointUpdate: () => void;
  60273. /**
  60274. * Adds new points to the point collection
  60275. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  60276. * @returns the list of created MultiLinePoint
  60277. */
  60278. add(...items: (AbstractMesh | Control | {
  60279. x: string | number;
  60280. y: string | number;
  60281. })[]): MultiLinePoint[];
  60282. /**
  60283. * Adds a new point to the point collection
  60284. * @param item defines the item (mesh, control or 2d coordiantes) to add
  60285. * @returns the created MultiLinePoint
  60286. */
  60287. push(item?: (AbstractMesh | Control | {
  60288. x: string | number;
  60289. y: string | number;
  60290. })): MultiLinePoint;
  60291. /**
  60292. * Remove a specific value or point from the active point collection
  60293. * @param value defines the value or point to remove
  60294. */
  60295. remove(value: number | MultiLinePoint): void;
  60296. /**
  60297. * Resets this object to initial state (no point)
  60298. */
  60299. reset(): void;
  60300. /**
  60301. * Resets all links
  60302. */
  60303. resetLinks(): void;
  60304. /** Gets or sets line width */
  60305. lineWidth: number;
  60306. horizontalAlignment: number;
  60307. verticalAlignment: number;
  60308. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  60309. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  60310. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60311. dispose(): void;
  60312. }
  60313. }
  60314. declare module BABYLON.GUI {
  60315. /**
  60316. * Class used to create radio button controls
  60317. */
  60318. export class RadioButton extends Control {
  60319. name?: string | undefined;
  60320. private _isChecked;
  60321. private _background;
  60322. private _checkSizeRatio;
  60323. private _thickness;
  60324. /** Gets or sets border thickness */
  60325. thickness: number;
  60326. /** Gets or sets group name */
  60327. group: string;
  60328. /** BABYLON.Observable raised when isChecked is changed */
  60329. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  60330. /** Gets or sets a value indicating the ratio between overall size and check size */
  60331. checkSizeRatio: number;
  60332. /** Gets or sets background color */
  60333. background: string;
  60334. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  60335. isChecked: boolean;
  60336. /**
  60337. * Creates a new RadioButton
  60338. * @param name defines the control name
  60339. */
  60340. constructor(name?: string | undefined);
  60341. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60342. /**
  60343. * Utility function to easily create a radio button with a header
  60344. * @param title defines the label to use for the header
  60345. * @param group defines the group to use for the radio button
  60346. * @param isChecked defines the initial state of the radio button
  60347. * @param onValueChanged defines the callback to call when value changes
  60348. * @returns a StackPanel containing the radio button and a textBlock
  60349. */
  60350. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  60351. }
  60352. }
  60353. declare module BABYLON.GUI {
  60354. /**
  60355. * Class used to create slider controls
  60356. */
  60357. export class BaseSlider extends Control {
  60358. name?: string | undefined;
  60359. protected _thumbWidth: ValueAndUnit;
  60360. private _minimum;
  60361. private _maximum;
  60362. private _value;
  60363. private _isVertical;
  60364. protected _barOffset: ValueAndUnit;
  60365. private _isThumbClamped;
  60366. protected _displayThumb: boolean;
  60367. private _step;
  60368. private _lastPointerDownID;
  60369. protected _effectiveBarOffset: number;
  60370. protected _renderLeft: number;
  60371. protected _renderTop: number;
  60372. protected _renderWidth: number;
  60373. protected _renderHeight: number;
  60374. protected _backgroundBoxLength: number;
  60375. protected _backgroundBoxThickness: number;
  60376. protected _effectiveThumbThickness: number;
  60377. /** BABYLON.Observable raised when the sldier value changes */
  60378. onValueChangedObservable: BABYLON.Observable<number>;
  60379. /** Gets or sets a boolean indicating if the thumb must be rendered */
  60380. displayThumb: boolean;
  60381. /** Gets or sets a step to apply to values (0 by default) */
  60382. step: number;
  60383. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  60384. barOffset: string | number;
  60385. /** Gets main bar offset in pixels*/
  60386. readonly barOffsetInPixels: number;
  60387. /** Gets or sets thumb width */
  60388. thumbWidth: string | number;
  60389. /** Gets thumb width in pixels */
  60390. readonly thumbWidthInPixels: number;
  60391. /** Gets or sets minimum value */
  60392. minimum: number;
  60393. /** Gets or sets maximum value */
  60394. maximum: number;
  60395. /** Gets or sets current value */
  60396. value: number;
  60397. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  60398. isVertical: boolean;
  60399. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  60400. isThumbClamped: boolean;
  60401. /**
  60402. * Creates a new BaseSlider
  60403. * @param name defines the control name
  60404. */
  60405. constructor(name?: string | undefined);
  60406. protected _getTypeName(): string;
  60407. protected _getThumbPosition(): number;
  60408. protected _getThumbThickness(type: string): number;
  60409. protected _prepareRenderingData(type: string): void;
  60410. private _pointerIsDown;
  60411. /** @hidden */
  60412. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean; private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void; private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  60413. }
  60414. }
  60415. declare module BABYLON.GUI {
  60416. /**
  60417. * Class used to create slider controls
  60418. */
  60419. export class Slider extends BaseSlider {
  60420. name?: string | undefined;
  60421. private _background;
  60422. private _borderColor;
  60423. private _isThumbCircle;
  60424. protected _displayValueBar: boolean;
  60425. /** Gets or sets a boolean indicating if the value bar must be rendered */
  60426. displayValueBar: boolean;
  60427. /** Gets or sets border color */
  60428. borderColor: string;
  60429. /** Gets or sets background color */
  60430. background: string;
  60431. /** Gets or sets a boolean indicating if the thumb should be round or square */
  60432. isThumbCircle: boolean;
  60433. /**
  60434. * Creates a new Slider
  60435. * @param name defines the control name
  60436. */
  60437. constructor(name?: string | undefined);
  60438. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  60439. }
  60440. }
  60441. declare module BABYLON.GUI {
  60442. /** Class used to create a RadioGroup
  60443. * which contains groups of radio buttons
  60444. */
  60445. export class SelectorGroup {
  60446. /** name of SelectorGroup */
  60447. name: string;
  60448. private _groupPanel;
  60449. private _selectors;
  60450. private _groupHeader;
  60451. /**
  60452. * Creates a new SelectorGroup
  60453. * @param name of group, used as a group heading
  60454. */
  60455. constructor(
  60456. /** name of SelectorGroup */
  60457. name: string);
  60458. /** Gets the groupPanel of the SelectorGroup */
  60459. readonly groupPanel: StackPanel;
  60460. /** Gets the selectors array */
  60461. readonly selectors: StackPanel[];
  60462. /** Gets and sets the group header */
  60463. header: string;
  60464. /** @hidden */
  60465. private _addGroupHeader;
  60466. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  60467. /** Removes the selector at the given position
  60468. * @param selectorNb the position of the selector within the group
  60469. */
  60470. removeSelector(selectorNb: number): void;
  60471. }
  60472. /** Class used to create a CheckboxGroup
  60473. * which contains groups of checkbox buttons
  60474. */
  60475. export class CheckboxGroup extends SelectorGroup {
  60476. /** Adds a checkbox as a control
  60477. * @param text is the label for the selector
  60478. * @param func is the function called when the Selector is checked
  60479. * @param checked is true when Selector is checked
  60480. */
  60481. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  60482. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  60483. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  60484. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  60485. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  60486. }
  60487. /** Class used to create a RadioGroup
  60488. * which contains groups of radio buttons
  60489. */
  60490. export class RadioGroup extends SelectorGroup {
  60491. private _selectNb;
  60492. /** Adds a radio button as a control
  60493. * @param label is the label for the selector
  60494. * @param func is the function called when the Selector is checked
  60495. * @param checked is true when Selector is checked
  60496. */
  60497. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  60498. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  60499. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  60500. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  60501. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  60502. }
  60503. /** Class used to create a SliderGroup
  60504. * which contains groups of slider buttons
  60505. */
  60506. export class SliderGroup extends SelectorGroup {
  60507. /**
  60508. * Adds a slider to the SelectorGroup
  60509. * @param label is the label for the SliderBar
  60510. * @param func is the function called when the Slider moves
  60511. * @param unit is a string describing the units used, eg degrees or metres
  60512. * @param min is the minimum value for the Slider
  60513. * @param max is the maximum value for the Slider
  60514. * @param value is the start value for the Slider between min and max
  60515. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  60516. */
  60517. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  60518. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  60519. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  60520. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  60521. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  60522. }
  60523. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  60524. * @see http://doc.babylonjs.com/how_to/selector
  60525. */
  60526. export class SelectionPanel extends Rectangle {
  60527. /** name of SelectionPanel */
  60528. name: string;
  60529. /** an array of SelectionGroups */
  60530. groups: SelectorGroup[];
  60531. private _panel;
  60532. private _buttonColor;
  60533. private _buttonBackground;
  60534. private _headerColor;
  60535. private _barColor;
  60536. private _barHeight;
  60537. private _spacerHeight;
  60538. private _labelColor;
  60539. private _groups;
  60540. private _bars;
  60541. /**
  60542. * Creates a new SelectionPanel
  60543. * @param name of SelectionPanel
  60544. * @param groups is an array of SelectionGroups
  60545. */
  60546. constructor(
  60547. /** name of SelectionPanel */
  60548. name: string,
  60549. /** an array of SelectionGroups */
  60550. groups?: SelectorGroup[]);
  60551. protected _getTypeName(): string;
  60552. /** Gets or sets the headerColor */
  60553. headerColor: string;
  60554. private _setHeaderColor;
  60555. /** Gets or sets the button color */
  60556. buttonColor: string;
  60557. private _setbuttonColor;
  60558. /** Gets or sets the label color */
  60559. labelColor: string;
  60560. private _setLabelColor;
  60561. /** Gets or sets the button background */
  60562. buttonBackground: string;
  60563. private _setButtonBackground;
  60564. /** Gets or sets the color of separator bar */
  60565. barColor: string;
  60566. private _setBarColor;
  60567. /** Gets or sets the height of separator bar */
  60568. barHeight: string;
  60569. private _setBarHeight;
  60570. /** Gets or sets the height of spacers*/
  60571. spacerHeight: string;
  60572. private _setSpacerHeight;
  60573. /** Adds a bar between groups */
  60574. private _addSpacer;
  60575. /** Add a group to the selection panel
  60576. * @param group is the selector group to add
  60577. */
  60578. addGroup(group: SelectorGroup): void;
  60579. /** Remove the group from the given position
  60580. * @param groupNb is the position of the group in the list
  60581. */
  60582. removeGroup(groupNb: number): void;
  60583. /** Change a group header label
  60584. * @param label is the new group header label
  60585. * @param groupNb is the number of the group to relabel
  60586. * */
  60587. setHeaderName(label: string, groupNb: number): void;
  60588. /** Change selector label to the one given
  60589. * @param label is the new selector label
  60590. * @param groupNb is the number of the groupcontaining the selector
  60591. * @param selectorNb is the number of the selector within a group to relabel
  60592. * */
  60593. relabel(label: string, groupNb: number, selectorNb: number): void;
  60594. /** For a given group position remove the selector at the given position
  60595. * @param groupNb is the number of the group to remove the selector from
  60596. * @param selectorNb is the number of the selector within the group
  60597. */
  60598. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  60599. /** For a given group position of correct type add a checkbox button
  60600. * @param groupNb is the number of the group to remove the selector from
  60601. * @param label is the label for the selector
  60602. * @param func is the function called when the Selector is checked
  60603. * @param checked is true when Selector is checked
  60604. */
  60605. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  60606. /** For a given group position of correct type add a radio button
  60607. * @param groupNb is the number of the group to remove the selector from
  60608. * @param label is the label for the selector
  60609. * @param func is the function called when the Selector is checked
  60610. * @param checked is true when Selector is checked
  60611. */
  60612. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  60613. /**
  60614. * For a given slider group add a slider
  60615. * @param groupNb is the number of the group to add the slider to
  60616. * @param label is the label for the Slider
  60617. * @param func is the function called when the Slider moves
  60618. * @param unit is a string describing the units used, eg degrees or metres
  60619. * @param min is the minimum value for the Slider
  60620. * @param max is the maximum value for the Slider
  60621. * @param value is the start value for the Slider between min and max
  60622. * @param onVal is the function used to format the value displayed, eg radians to degrees
  60623. */
  60624. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  60625. }
  60626. }
  60627. declare module BABYLON.GUI {
  60628. /**
  60629. * Class used to hold a the container for ScrollViewer
  60630. * @hidden
  60631. */
  60632. export class _ScrollViewerWindow extends Container {
  60633. parentClientWidth: number;
  60634. parentClientHeight: number;
  60635. /**
  60636. * Creates a new ScrollViewerWindow
  60637. * @param name of ScrollViewerWindow
  60638. */
  60639. constructor(name?: string);
  60640. protected _getTypeName(): string;
  60641. /** @hidden */
  60642. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60643. protected _postMeasure(): void;
  60644. }
  60645. }
  60646. declare module BABYLON.GUI {
  60647. /**
  60648. * Class used to create slider controls
  60649. */
  60650. export class ScrollBar extends BaseSlider {
  60651. name?: string | undefined;
  60652. private _background;
  60653. private _borderColor;
  60654. private _thumbMeasure;
  60655. /** Gets or sets border color */
  60656. borderColor: string;
  60657. /** Gets or sets background color */
  60658. background: string;
  60659. /**
  60660. * Creates a new Slider
  60661. * @param name defines the control name
  60662. */
  60663. constructor(name?: string | undefined);
  60664. protected _getTypeName(): string;
  60665. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  60666. private _first;
  60667. private _originX;
  60668. private _originY;
  60669. /** @hidden */
  60670. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  60671. }
  60672. }
  60673. declare module BABYLON.GUI {
  60674. /**
  60675. * Class used to hold a viewer window and sliders in a grid
  60676. */
  60677. export class ScrollViewer extends Rectangle {
  60678. private _grid;
  60679. private _horizontalBarSpace;
  60680. private _verticalBarSpace;
  60681. private _dragSpace;
  60682. private _horizontalBar;
  60683. private _verticalBar;
  60684. private _barColor;
  60685. private _barBackground;
  60686. private _barSize;
  60687. private _endLeft;
  60688. private _endTop;
  60689. private _window;
  60690. private _pointerIsOver;
  60691. private _wheelPrecision;
  60692. private _onPointerObserver;
  60693. private _clientWidth;
  60694. private _clientHeight;
  60695. /**
  60696. * Gets the horizontal scrollbar
  60697. */
  60698. readonly horizontalBar: ScrollBar;
  60699. /**
  60700. * Gets the vertical scrollbar
  60701. */
  60702. readonly verticalBar: ScrollBar;
  60703. /**
  60704. * Adds a new control to the current container
  60705. * @param control defines the control to add
  60706. * @returns the current container
  60707. */
  60708. addControl(control: BABYLON.Nullable<Control>): Container;
  60709. /**
  60710. * Removes a control from the current container
  60711. * @param control defines the control to remove
  60712. * @returns the current container
  60713. */
  60714. removeControl(control: Control): Container;
  60715. /** Gets the list of children */
  60716. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  60717. /**
  60718. * Creates a new ScrollViewer
  60719. * @param name of ScrollViewer
  60720. */
  60721. constructor(name?: string);
  60722. /** Reset the scroll viewer window to initial size */
  60723. resetWindow(): void;
  60724. protected _getTypeName(): string;
  60725. private _buildClientSizes;
  60726. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  60727. protected _postMeasure(): void;
  60728. /**
  60729. * Gets or sets the mouse wheel precision
  60730. * from 0 to 1 with a default value of 0.05
  60731. * */
  60732. wheelPrecision: number;
  60733. /** Gets or sets the bar color */
  60734. barColor: string;
  60735. /** Gets or sets the size of the bar */
  60736. barSize: number;
  60737. /** Gets or sets the bar background */
  60738. barBackground: string;
  60739. /** @hidden */
  60740. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  60741. /** @hidden */
  60742. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  60743. /** Releases associated resources */
  60744. dispose(): void;
  60745. }
  60746. }
  60747. declare module BABYLON.GUI {
  60748. /** Class used to render a grid */
  60749. export class DisplayGrid extends Control {
  60750. name?: string | undefined;
  60751. private _cellWidth;
  60752. private _cellHeight;
  60753. private _minorLineTickness;
  60754. private _minorLineColor;
  60755. private _majorLineTickness;
  60756. private _majorLineColor;
  60757. private _majorLineFrequency;
  60758. private _background;
  60759. private _displayMajorLines;
  60760. private _displayMinorLines;
  60761. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  60762. displayMinorLines: boolean;
  60763. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  60764. displayMajorLines: boolean;
  60765. /** Gets or sets background color (Black by default) */
  60766. background: string;
  60767. /** Gets or sets the width of each cell (20 by default) */
  60768. cellWidth: number;
  60769. /** Gets or sets the height of each cell (20 by default) */
  60770. cellHeight: number;
  60771. /** Gets or sets the tickness of minor lines (1 by default) */
  60772. minorLineTickness: number;
  60773. /** Gets or sets the color of minor lines (DarkGray by default) */
  60774. minorLineColor: string;
  60775. /** Gets or sets the tickness of major lines (2 by default) */
  60776. majorLineTickness: number;
  60777. /** Gets or sets the color of major lines (White by default) */
  60778. majorLineColor: string;
  60779. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  60780. majorLineFrequency: number;
  60781. /**
  60782. * Creates a new GridDisplayRectangle
  60783. * @param name defines the control name
  60784. */
  60785. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  60786. protected _getTypeName(): string;
  60787. }
  60788. }
  60789. declare module BABYLON.GUI {
  60790. /**
  60791. * Class used to create slider controls based on images
  60792. */
  60793. export class ImageBasedSlider extends BaseSlider {
  60794. name?: string | undefined;
  60795. private _backgroundImage;
  60796. private _thumbImage;
  60797. private _valueBarImage;
  60798. private _tempMeasure;
  60799. displayThumb: boolean;
  60800. /**
  60801. * Gets or sets the image used to render the background
  60802. */
  60803. backgroundImage: Image;
  60804. /**
  60805. * Gets or sets the image used to render the value bar
  60806. */
  60807. valueBarImage: Image;
  60808. /**
  60809. * Gets or sets the image used to render the thumb
  60810. */
  60811. thumbImage: Image;
  60812. /**
  60813. * Creates a new ImageBasedSlider
  60814. * @param name defines the control name
  60815. */
  60816. constructor(name?: string | undefined);
  60817. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  60818. }
  60819. }
  60820. declare module BABYLON.GUI {
  60821. /**
  60822. * Forcing an export so that this code will execute
  60823. * @hidden
  60824. */
  60825. const name = "Statics";
  60826. }
  60827. declare module BABYLON.GUI {
  60828. /**
  60829. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  60830. */
  60831. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  60832. /**
  60833. * Define the instrumented AdvancedDynamicTexture.
  60834. */
  60835. texture: AdvancedDynamicTexture;
  60836. private _captureRenderTime;
  60837. private _renderTime;
  60838. private _captureLayoutTime;
  60839. private _layoutTime;
  60840. private _onBeginRenderObserver;
  60841. private _onEndRenderObserver;
  60842. private _onBeginLayoutObserver;
  60843. private _onEndLayoutObserver;
  60844. /**
  60845. * Gets the perf counter used to capture render time
  60846. */
  60847. readonly renderTimeCounter: BABYLON.PerfCounter;
  60848. /**
  60849. * Gets the perf counter used to capture layout time
  60850. */
  60851. readonly layoutTimeCounter: BABYLON.PerfCounter;
  60852. /**
  60853. * Enable or disable the render time capture
  60854. */
  60855. captureRenderTime: boolean;
  60856. /**
  60857. * Enable or disable the layout time capture
  60858. */
  60859. captureLayoutTime: boolean;
  60860. /**
  60861. * Instantiates a new advanced dynamic texture instrumentation.
  60862. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  60863. * @param texture Defines the AdvancedDynamicTexture to instrument
  60864. */
  60865. constructor(
  60866. /**
  60867. * Define the instrumented AdvancedDynamicTexture.
  60868. */
  60869. texture: AdvancedDynamicTexture);
  60870. /**
  60871. * Dispose and release associated resources.
  60872. */
  60873. dispose(): void;
  60874. }
  60875. }
  60876. declare module BABYLON.GUI {
  60877. /**
  60878. * Class used to create containers for controls
  60879. */
  60880. export class Container3D extends Control3D {
  60881. private _blockLayout;
  60882. /**
  60883. * Gets the list of child controls
  60884. */
  60885. protected _children: Control3D[];
  60886. /**
  60887. * Gets the list of child controls
  60888. */
  60889. readonly children: Array<Control3D>;
  60890. /**
  60891. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  60892. * This is helpful to optimize layout operation when adding multiple children in a row
  60893. */
  60894. blockLayout: boolean;
  60895. /**
  60896. * Creates a new container
  60897. * @param name defines the container name
  60898. */
  60899. constructor(name?: string);
  60900. /**
  60901. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  60902. * @returns the current container
  60903. */
  60904. updateLayout(): Container3D;
  60905. /**
  60906. * Gets a boolean indicating if the given control is in the children of this control
  60907. * @param control defines the control to check
  60908. * @returns true if the control is in the child list
  60909. */
  60910. containsControl(control: Control3D): boolean;
  60911. /**
  60912. * Adds a control to the children of this control
  60913. * @param control defines the control to add
  60914. * @returns the current container
  60915. */
  60916. addControl(control: Control3D): Container3D;
  60917. /**
  60918. * This function will be called everytime a new control is added
  60919. */
  60920. protected _arrangeChildren(): void;
  60921. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  60922. /**
  60923. * Removes a control from the children of this control
  60924. * @param control defines the control to remove
  60925. * @returns the current container
  60926. */
  60927. removeControl(control: Control3D): Container3D;
  60928. protected _getTypeName(): string;
  60929. /**
  60930. * Releases all associated resources
  60931. */
  60932. dispose(): void;
  60933. /** Control rotation will remain unchanged */
  60934. static readonly UNSET_ORIENTATION: number;
  60935. /** Control will rotate to make it look at sphere central axis */
  60936. static readonly FACEORIGIN_ORIENTATION: number;
  60937. /** Control will rotate to make it look back at sphere central axis */
  60938. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  60939. /** Control will rotate to look at z axis (0, 0, 1) */
  60940. static readonly FACEFORWARD_ORIENTATION: number;
  60941. /** Control will rotate to look at negative z axis (0, 0, -1) */
  60942. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  60943. }
  60944. }
  60945. declare module BABYLON.GUI {
  60946. /**
  60947. * Class used to manage 3D user interface
  60948. * @see http://doc.babylonjs.com/how_to/gui3d
  60949. */
  60950. export class GUI3DManager implements BABYLON.IDisposable {
  60951. private _scene;
  60952. private _sceneDisposeObserver;
  60953. private _utilityLayer;
  60954. private _rootContainer;
  60955. private _pointerObserver;
  60956. private _pointerOutObserver;
  60957. /** @hidden */ private _lastPickedControl: Control3D;
  60958. /** @hidden */ private _lastControlOver: {
  60959. [pointerId: number]: Control3D;
  60960. };
  60961. /** @hidden */ private _lastControlDown: {
  60962. [pointerId: number]: Control3D;
  60963. };
  60964. /**
  60965. * BABYLON.Observable raised when the point picked by the pointer events changed
  60966. */
  60967. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  60968. /** @hidden */ private _sharedMaterials: {
  60969. [key: string]: BABYLON.Material;
  60970. };
  60971. /** Gets the hosting scene */
  60972. readonly scene: BABYLON.Scene;
  60973. /** Gets associated utility layer */
  60974. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  60975. /**
  60976. * Creates a new GUI3DManager
  60977. * @param scene
  60978. */
  60979. constructor(scene?: BABYLON.Scene);
  60980. private _handlePointerOut;
  60981. private _doPicking;
  60982. /**
  60983. * Gets the root container
  60984. */
  60985. readonly rootContainer: Container3D;
  60986. /**
  60987. * Gets a boolean indicating if the given control is in the root child list
  60988. * @param control defines the control to check
  60989. * @returns true if the control is in the root child list
  60990. */
  60991. containsControl(control: Control3D): boolean;
  60992. /**
  60993. * Adds a control to the root child list
  60994. * @param control defines the control to add
  60995. * @returns the current manager
  60996. */
  60997. addControl(control: Control3D): GUI3DManager;
  60998. /**
  60999. * Removes a control from the root child list
  61000. * @param control defines the control to remove
  61001. * @returns the current container
  61002. */
  61003. removeControl(control: Control3D): GUI3DManager;
  61004. /**
  61005. * Releases all associated resources
  61006. */
  61007. dispose(): void;
  61008. }
  61009. }
  61010. declare module BABYLON.GUI {
  61011. /**
  61012. * Class used to transport BABYLON.Vector3 information for pointer events
  61013. */
  61014. export class Vector3WithInfo extends BABYLON.Vector3 {
  61015. /** defines the current mouse button index */
  61016. buttonIndex: number;
  61017. /**
  61018. * Creates a new Vector3WithInfo
  61019. * @param source defines the vector3 data to transport
  61020. * @param buttonIndex defines the current mouse button index
  61021. */
  61022. constructor(source: BABYLON.Vector3,
  61023. /** defines the current mouse button index */
  61024. buttonIndex?: number);
  61025. }
  61026. }
  61027. declare module BABYLON.GUI {
  61028. /**
  61029. * Class used as base class for controls
  61030. */
  61031. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  61032. /** Defines the control name */
  61033. name?: string | undefined;
  61034. /** @hidden */ private _host: GUI3DManager;
  61035. private _node;
  61036. private _downCount;
  61037. private _enterCount;
  61038. private _downPointerIds;
  61039. private _isVisible;
  61040. /** Gets or sets the control position in world space */
  61041. position: BABYLON.Vector3;
  61042. /** Gets or sets the control scaling in world space */
  61043. scaling: BABYLON.Vector3;
  61044. /** Callback used to start pointer enter animation */
  61045. pointerEnterAnimation: () => void;
  61046. /** Callback used to start pointer out animation */
  61047. pointerOutAnimation: () => void;
  61048. /** Callback used to start pointer down animation */
  61049. pointerDownAnimation: () => void;
  61050. /** Callback used to start pointer up animation */
  61051. pointerUpAnimation: () => void;
  61052. /**
  61053. * An event triggered when the pointer move over the control
  61054. */
  61055. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  61056. /**
  61057. * An event triggered when the pointer move out of the control
  61058. */
  61059. onPointerOutObservable: BABYLON.Observable<Control3D>;
  61060. /**
  61061. * An event triggered when the pointer taps the control
  61062. */
  61063. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  61064. /**
  61065. * An event triggered when pointer is up
  61066. */
  61067. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  61068. /**
  61069. * An event triggered when a control is clicked on (with a mouse)
  61070. */
  61071. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  61072. /**
  61073. * An event triggered when pointer enters the control
  61074. */
  61075. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  61076. /**
  61077. * Gets or sets the parent container
  61078. */
  61079. parent: BABYLON.Nullable<Container3D>;
  61080. private _behaviors;
  61081. /**
  61082. * Gets the list of attached behaviors
  61083. * @see http://doc.babylonjs.com/features/behaviour
  61084. */
  61085. readonly behaviors: BABYLON.Behavior<Control3D>[];
  61086. /**
  61087. * Attach a behavior to the control
  61088. * @see http://doc.babylonjs.com/features/behaviour
  61089. * @param behavior defines the behavior to attach
  61090. * @returns the current control
  61091. */
  61092. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  61093. /**
  61094. * Remove an attached behavior
  61095. * @see http://doc.babylonjs.com/features/behaviour
  61096. * @param behavior defines the behavior to attach
  61097. * @returns the current control
  61098. */
  61099. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  61100. /**
  61101. * Gets an attached behavior by name
  61102. * @param name defines the name of the behavior to look for
  61103. * @see http://doc.babylonjs.com/features/behaviour
  61104. * @returns null if behavior was not found else the requested behavior
  61105. */
  61106. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  61107. /** Gets or sets a boolean indicating if the control is visible */
  61108. isVisible: boolean;
  61109. /**
  61110. * Creates a new control
  61111. * @param name defines the control name
  61112. */
  61113. constructor(
  61114. /** Defines the control name */
  61115. name?: string | undefined);
  61116. /**
  61117. * Gets a string representing the class name
  61118. */
  61119. readonly typeName: string;
  61120. /**
  61121. * Get the current class name of the control.
  61122. * @returns current class name
  61123. */
  61124. getClassName(): string;
  61125. protected _getTypeName(): string;
  61126. /**
  61127. * Gets the transform node used by this control
  61128. */
  61129. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  61130. /**
  61131. * Gets the mesh used to render this control
  61132. */
  61133. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61134. /**
  61135. * Link the control as child of the given node
  61136. * @param node defines the node to link to. Use null to unlink the control
  61137. * @returns the current control
  61138. */
  61139. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  61140. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  61141. /**
  61142. * Node creation.
  61143. * Can be overriden by children
  61144. * @param scene defines the scene where the node must be attached
  61145. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  61146. */
  61147. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  61148. /**
  61149. * Affect a material to the given mesh
  61150. * @param mesh defines the mesh which will represent the control
  61151. */
  61152. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  61153. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  61154. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  61155. /** @hidden */ private _onPointerOut(target: Control3D): void;
  61156. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  61157. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61158. /** @hidden */
  61159. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61160. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  61161. /** @hidden */ private _disposeNode(): void;
  61162. /**
  61163. * Releases all associated resources
  61164. */
  61165. dispose(): void;
  61166. }
  61167. }
  61168. declare module BABYLON.GUI {
  61169. /**
  61170. * Class used as a root to all buttons
  61171. */
  61172. export class AbstractButton3D extends Control3D {
  61173. /**
  61174. * Creates a new button
  61175. * @param name defines the control name
  61176. */
  61177. constructor(name?: string);
  61178. protected _getTypeName(): string;
  61179. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61180. }
  61181. }
  61182. declare module BABYLON.GUI {
  61183. /**
  61184. * Class used to create a button in 3D
  61185. */
  61186. export class Button3D extends AbstractButton3D {
  61187. /** @hidden */
  61188. protected _currentMaterial: BABYLON.Material;
  61189. private _facadeTexture;
  61190. private _content;
  61191. private _contentResolution;
  61192. private _contentScaleRatio;
  61193. /**
  61194. * Gets or sets the texture resolution used to render content (512 by default)
  61195. */
  61196. contentResolution: BABYLON.int;
  61197. /**
  61198. * Gets or sets the texture scale ratio used to render content (2 by default)
  61199. */
  61200. contentScaleRatio: number;
  61201. protected _disposeFacadeTexture(): void;
  61202. protected _resetContent(): void;
  61203. /**
  61204. * Creates a new button
  61205. * @param name defines the control name
  61206. */
  61207. constructor(name?: string);
  61208. /**
  61209. * Gets or sets the GUI 2D content used to display the button's facade
  61210. */
  61211. content: Control;
  61212. /**
  61213. * Apply the facade texture (created from the content property).
  61214. * This function can be overloaded by child classes
  61215. * @param facadeTexture defines the AdvancedDynamicTexture to use
  61216. */
  61217. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  61218. protected _getTypeName(): string;
  61219. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61220. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  61221. /**
  61222. * Releases all associated resources
  61223. */
  61224. dispose(): void;
  61225. }
  61226. }
  61227. declare module BABYLON.GUI {
  61228. /**
  61229. * Abstract class used to create a container panel deployed on the surface of a volume
  61230. */
  61231. export abstract class VolumeBasedPanel extends Container3D {
  61232. private _columns;
  61233. private _rows;
  61234. private _rowThenColum;
  61235. private _orientation;
  61236. protected _cellWidth: number;
  61237. protected _cellHeight: number;
  61238. /**
  61239. * Gets or sets the distance between elements
  61240. */
  61241. margin: number;
  61242. /**
  61243. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  61244. * | Value | Type | Description |
  61245. * | ----- | ----------------------------------- | ----------- |
  61246. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  61247. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  61248. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  61249. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  61250. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  61251. */
  61252. orientation: number;
  61253. /**
  61254. * Gets or sets the number of columns requested (10 by default).
  61255. * The panel will automatically compute the number of rows based on number of child controls.
  61256. */
  61257. columns: BABYLON.int;
  61258. /**
  61259. * Gets or sets a the number of rows requested.
  61260. * The panel will automatically compute the number of columns based on number of child controls.
  61261. */
  61262. rows: BABYLON.int;
  61263. /**
  61264. * Creates new VolumeBasedPanel
  61265. */
  61266. constructor();
  61267. protected _arrangeChildren(): void;
  61268. /** Child classes must implement this function to provide correct control positioning */
  61269. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61270. /** Child classes can implement this function to provide additional processing */
  61271. protected _finalProcessing(): void;
  61272. }
  61273. }
  61274. declare module BABYLON.GUI {
  61275. /**
  61276. * Class used to create a container panel deployed on the surface of a cylinder
  61277. */
  61278. export class CylinderPanel extends VolumeBasedPanel {
  61279. private _radius;
  61280. /**
  61281. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  61282. */
  61283. radius: BABYLON.float;
  61284. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61285. private _cylindricalMapping;
  61286. }
  61287. }
  61288. declare module BABYLON.GUI {
  61289. /** @hidden */
  61290. export var fluentVertexShader: {
  61291. name: string;
  61292. shader: string;
  61293. };
  61294. }
  61295. declare module BABYLON.GUI {
  61296. /** @hidden */
  61297. export var fluentPixelShader: {
  61298. name: string;
  61299. shader: string;
  61300. };
  61301. }
  61302. declare module BABYLON.GUI {
  61303. /** @hidden */
  61304. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  61305. INNERGLOW: boolean;
  61306. BORDER: boolean;
  61307. HOVERLIGHT: boolean;
  61308. TEXTURE: boolean;
  61309. constructor();
  61310. }
  61311. /**
  61312. * Class used to render controls with fluent desgin
  61313. */
  61314. export class FluentMaterial extends BABYLON.PushMaterial {
  61315. /**
  61316. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  61317. */
  61318. innerGlowColorIntensity: number;
  61319. /**
  61320. * Gets or sets the inner glow color (white by default)
  61321. */
  61322. innerGlowColor: BABYLON.Color3;
  61323. /**
  61324. * Gets or sets alpha value (default is 1.0)
  61325. */
  61326. alpha: number;
  61327. /**
  61328. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  61329. */
  61330. albedoColor: BABYLON.Color3;
  61331. /**
  61332. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  61333. */
  61334. renderBorders: boolean;
  61335. /**
  61336. * Gets or sets border width (default is 0.5)
  61337. */
  61338. borderWidth: number;
  61339. /**
  61340. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  61341. */
  61342. edgeSmoothingValue: number;
  61343. /**
  61344. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  61345. */
  61346. borderMinValue: number;
  61347. /**
  61348. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  61349. */
  61350. renderHoverLight: boolean;
  61351. /**
  61352. * Gets or sets the radius used to render the hover light (default is 1.0)
  61353. */
  61354. hoverRadius: number;
  61355. /**
  61356. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  61357. */
  61358. hoverColor: BABYLON.Color4;
  61359. /**
  61360. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  61361. */
  61362. hoverPosition: BABYLON.Vector3;
  61363. private _albedoTexture;
  61364. /** Gets or sets the texture to use for albedo color */
  61365. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  61366. /**
  61367. * Creates a new Fluent material
  61368. * @param name defines the name of the material
  61369. * @param scene defines the hosting scene
  61370. */
  61371. constructor(name: string, scene: BABYLON.Scene);
  61372. needAlphaBlending(): boolean;
  61373. needAlphaTesting(): boolean;
  61374. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  61375. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  61376. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  61377. getActiveTextures(): BABYLON.BaseTexture[];
  61378. hasTexture(texture: BABYLON.BaseTexture): boolean;
  61379. dispose(forceDisposeEffect?: boolean): void;
  61380. clone(name: string): FluentMaterial;
  61381. serialize(): any;
  61382. getClassName(): string;
  61383. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  61384. }
  61385. }
  61386. declare module BABYLON.GUI {
  61387. /**
  61388. * Class used to create a holographic button in 3D
  61389. */
  61390. export class HolographicButton extends Button3D {
  61391. private _backPlate;
  61392. private _textPlate;
  61393. private _frontPlate;
  61394. private _text;
  61395. private _imageUrl;
  61396. private _shareMaterials;
  61397. private _frontMaterial;
  61398. private _backMaterial;
  61399. private _plateMaterial;
  61400. private _pickedPointObserver;
  61401. private _tooltipFade;
  61402. private _tooltipTextBlock;
  61403. private _tooltipTexture;
  61404. private _tooltipMesh;
  61405. private _tooltipHoverObserver;
  61406. private _tooltipOutObserver;
  61407. private _disposeTooltip;
  61408. /**
  61409. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  61410. */
  61411. tooltipText: BABYLON.Nullable<string>;
  61412. /**
  61413. * Gets or sets text for the button
  61414. */
  61415. text: string;
  61416. /**
  61417. * Gets or sets the image url for the button
  61418. */
  61419. imageUrl: string;
  61420. /**
  61421. * Gets the back material used by this button
  61422. */
  61423. readonly backMaterial: FluentMaterial;
  61424. /**
  61425. * Gets the front material used by this button
  61426. */
  61427. readonly frontMaterial: FluentMaterial;
  61428. /**
  61429. * Gets the plate material used by this button
  61430. */
  61431. readonly plateMaterial: BABYLON.StandardMaterial;
  61432. /**
  61433. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  61434. */
  61435. readonly shareMaterials: boolean;
  61436. /**
  61437. * Creates a new button
  61438. * @param name defines the control name
  61439. */
  61440. constructor(name?: string, shareMaterials?: boolean);
  61441. protected _getTypeName(): string;
  61442. private _rebuildContent;
  61443. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61444. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  61445. private _createBackMaterial;
  61446. private _createFrontMaterial;
  61447. private _createPlateMaterial;
  61448. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  61449. /**
  61450. * Releases all associated resources
  61451. */
  61452. dispose(): void;
  61453. }
  61454. }
  61455. declare module BABYLON.GUI {
  61456. /**
  61457. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  61458. */
  61459. export class MeshButton3D extends Button3D {
  61460. /** @hidden */
  61461. protected _currentMesh: BABYLON.Mesh;
  61462. /**
  61463. * Creates a new 3D button based on a mesh
  61464. * @param mesh mesh to become a 3D button
  61465. * @param name defines the control name
  61466. */
  61467. constructor(mesh: BABYLON.Mesh, name?: string);
  61468. protected _getTypeName(): string;
  61469. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  61470. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  61471. }
  61472. }
  61473. declare module BABYLON.GUI {
  61474. /**
  61475. * Class used to create a container panel deployed on the surface of a plane
  61476. */
  61477. export class PlanePanel extends VolumeBasedPanel {
  61478. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61479. }
  61480. }
  61481. declare module BABYLON.GUI {
  61482. /**
  61483. * Class used to create a container panel where items get randomized planar mapping
  61484. */
  61485. export class ScatterPanel extends VolumeBasedPanel {
  61486. private _iteration;
  61487. /**
  61488. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  61489. */
  61490. iteration: BABYLON.float;
  61491. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61492. private _scatterMapping;
  61493. protected _finalProcessing(): void;
  61494. }
  61495. }
  61496. declare module BABYLON.GUI {
  61497. /**
  61498. * Class used to create a container panel deployed on the surface of a sphere
  61499. */
  61500. export class SpherePanel extends VolumeBasedPanel {
  61501. private _radius;
  61502. /**
  61503. * Gets or sets the radius of the sphere where to project controls (5 by default)
  61504. */
  61505. radius: BABYLON.float;
  61506. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  61507. private _sphericalMapping;
  61508. }
  61509. }
  61510. declare module BABYLON.GUI {
  61511. /**
  61512. * Class used to create a stack panel in 3D on XY plane
  61513. */
  61514. export class StackPanel3D extends Container3D {
  61515. private _isVertical;
  61516. /**
  61517. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  61518. */
  61519. isVertical: boolean;
  61520. /**
  61521. * Gets or sets the distance between elements
  61522. */
  61523. margin: number;
  61524. /**
  61525. * Creates new StackPanel
  61526. * @param isVertical
  61527. */
  61528. constructor(isVertical?: boolean);
  61529. protected _arrangeChildren(): void;
  61530. }
  61531. }
  61532. declare module BABYLON {
  61533. /**
  61534. * Mode that determines the coordinate system to use.
  61535. */
  61536. export enum GLTFLoaderCoordinateSystemMode {
  61537. /**
  61538. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  61539. */
  61540. AUTO = 0,
  61541. /**
  61542. * Sets the useRightHandedSystem flag on the scene.
  61543. */
  61544. FORCE_RIGHT_HANDED = 1
  61545. }
  61546. /**
  61547. * Mode that determines what animations will start.
  61548. */
  61549. export enum GLTFLoaderAnimationStartMode {
  61550. /**
  61551. * No animation will start.
  61552. */
  61553. NONE = 0,
  61554. /**
  61555. * The first animation will start.
  61556. */
  61557. FIRST = 1,
  61558. /**
  61559. * All animations will start.
  61560. */
  61561. ALL = 2
  61562. }
  61563. /**
  61564. * Interface that contains the data for the glTF asset.
  61565. */
  61566. export interface IGLTFLoaderData {
  61567. /**
  61568. * Object that represents the glTF JSON.
  61569. */
  61570. json: Object;
  61571. /**
  61572. * The BIN chunk of a binary glTF.
  61573. */
  61574. bin: Nullable<ArrayBufferView>;
  61575. }
  61576. /**
  61577. * Interface for extending the loader.
  61578. */
  61579. export interface IGLTFLoaderExtension {
  61580. /**
  61581. * The name of this extension.
  61582. */
  61583. readonly name: string;
  61584. /**
  61585. * Defines whether this extension is enabled.
  61586. */
  61587. enabled: boolean;
  61588. }
  61589. /**
  61590. * Loader state.
  61591. */
  61592. export enum GLTFLoaderState {
  61593. /**
  61594. * The asset is loading.
  61595. */
  61596. LOADING = 0,
  61597. /**
  61598. * The asset is ready for rendering.
  61599. */
  61600. READY = 1,
  61601. /**
  61602. * The asset is completely loaded.
  61603. */
  61604. COMPLETE = 2
  61605. }
  61606. /** @hidden */
  61607. export interface IGLTFLoader extends IDisposable {
  61608. readonly state: Nullable<GLTFLoaderState>;
  61609. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  61610. meshes: AbstractMesh[];
  61611. particleSystems: IParticleSystem[];
  61612. skeletons: Skeleton[];
  61613. animationGroups: AnimationGroup[];
  61614. }>;
  61615. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  61616. }
  61617. /**
  61618. * File loader for loading glTF files into a scene.
  61619. */
  61620. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  61621. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  61622. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  61623. /**
  61624. * Raised when the asset has been parsed
  61625. */
  61626. onParsedObservable: Observable<IGLTFLoaderData>;
  61627. private _onParsedObserver;
  61628. /**
  61629. * Raised when the asset has been parsed
  61630. */
  61631. onParsed: (loaderData: IGLTFLoaderData) => void;
  61632. /**
  61633. * 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.
  61634. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  61635. * Defaults to true.
  61636. * @hidden
  61637. */
  61638. static IncrementalLoading: boolean;
  61639. /**
  61640. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  61641. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  61642. * @hidden
  61643. */
  61644. static HomogeneousCoordinates: boolean;
  61645. /**
  61646. * The coordinate system mode. Defaults to AUTO.
  61647. */
  61648. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  61649. /**
  61650. * The animation start mode. Defaults to FIRST.
  61651. */
  61652. animationStartMode: GLTFLoaderAnimationStartMode;
  61653. /**
  61654. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  61655. */
  61656. compileMaterials: boolean;
  61657. /**
  61658. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  61659. */
  61660. useClipPlane: boolean;
  61661. /**
  61662. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  61663. */
  61664. compileShadowGenerators: boolean;
  61665. /**
  61666. * Defines if the Alpha blended materials are only applied as coverage.
  61667. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  61668. * If true, no extra effects are applied to transparent pixels.
  61669. */
  61670. transparencyAsCoverage: boolean;
  61671. /**
  61672. * Function called before loading a url referenced by the asset.
  61673. */
  61674. preprocessUrlAsync: (url: string) => Promise<string>;
  61675. /**
  61676. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  61677. */
  61678. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  61679. private _onMeshLoadedObserver;
  61680. /**
  61681. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  61682. */
  61683. onMeshLoaded: (mesh: AbstractMesh) => void;
  61684. /**
  61685. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  61686. */
  61687. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  61688. private _onTextureLoadedObserver;
  61689. /**
  61690. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  61691. */
  61692. onTextureLoaded: (texture: BaseTexture) => void;
  61693. /**
  61694. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  61695. */
  61696. readonly onMaterialLoadedObservable: Observable<Material>;
  61697. private _onMaterialLoadedObserver;
  61698. /**
  61699. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  61700. */
  61701. onMaterialLoaded: (material: Material) => void;
  61702. /**
  61703. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  61704. */
  61705. readonly onCameraLoadedObservable: Observable<Camera>;
  61706. private _onCameraLoadedObserver;
  61707. /**
  61708. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  61709. */
  61710. onCameraLoaded: (camera: Camera) => void;
  61711. /**
  61712. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  61713. * For assets with LODs, raised when all of the LODs are complete.
  61714. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  61715. */
  61716. readonly onCompleteObservable: Observable<void>;
  61717. private _onCompleteObserver;
  61718. /**
  61719. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  61720. * For assets with LODs, raised when all of the LODs are complete.
  61721. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  61722. */
  61723. onComplete: () => void;
  61724. /**
  61725. * Observable raised when an error occurs.
  61726. */
  61727. readonly onErrorObservable: Observable<any>;
  61728. private _onErrorObserver;
  61729. /**
  61730. * Callback raised when an error occurs.
  61731. */
  61732. onError: (reason: any) => void;
  61733. /**
  61734. * Observable raised after the loader is disposed.
  61735. */
  61736. readonly onDisposeObservable: Observable<void>;
  61737. private _onDisposeObserver;
  61738. /**
  61739. * Callback raised after the loader is disposed.
  61740. */
  61741. onDispose: () => void;
  61742. /**
  61743. * Observable raised after a loader extension is created.
  61744. * Set additional options for a loader extension in this event.
  61745. */
  61746. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  61747. private _onExtensionLoadedObserver;
  61748. /**
  61749. * Callback raised after a loader extension is created.
  61750. */
  61751. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  61752. /**
  61753. * Defines if the loader logging is enabled.
  61754. */
  61755. loggingEnabled: boolean;
  61756. /**
  61757. * Defines if the loader should capture performance counters.
  61758. */
  61759. capturePerformanceCounters: boolean;
  61760. /**
  61761. * Defines if the loader should validate the asset.
  61762. */
  61763. validate: boolean;
  61764. /**
  61765. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  61766. */
  61767. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  61768. private _onValidatedObserver;
  61769. /**
  61770. * Callback raised after a loader extension is created.
  61771. */
  61772. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  61773. private _loader;
  61774. /**
  61775. * Name of the loader ("gltf")
  61776. */
  61777. name: string;
  61778. /**
  61779. * Supported file extensions of the loader (.gltf, .glb)
  61780. */
  61781. extensions: ISceneLoaderPluginExtensions;
  61782. /**
  61783. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  61784. */
  61785. dispose(): void;
  61786. /** @hidden */ private _clear(): void;
  61787. /**
  61788. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  61789. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  61790. * @param scene the scene the meshes should be added to
  61791. * @param data the glTF data to load
  61792. * @param rootUrl root url to load from
  61793. * @param onProgress event that fires when loading progress has occured
  61794. * @param fileName Defines the name of the file to load
  61795. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  61796. */
  61797. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  61798. meshes: AbstractMesh[];
  61799. particleSystems: IParticleSystem[];
  61800. skeletons: Skeleton[];
  61801. animationGroups: AnimationGroup[];
  61802. }>;
  61803. /**
  61804. * Imports all objects from the loaded glTF data and adds them to the scene
  61805. * @param scene the scene the objects should be added to
  61806. * @param data the glTF data to load
  61807. * @param rootUrl root url to load from
  61808. * @param onProgress event that fires when loading progress has occured
  61809. * @param fileName Defines the name of the file to load
  61810. * @returns a promise which completes when objects have been loaded to the scene
  61811. */
  61812. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  61813. /**
  61814. * Load into an asset container.
  61815. * @param scene The scene to load into
  61816. * @param data The data to import
  61817. * @param rootUrl The root url for scene and resources
  61818. * @param onProgress The callback when the load progresses
  61819. * @param fileName Defines the name of the file to load
  61820. * @returns The loaded asset container
  61821. */
  61822. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  61823. /**
  61824. * If the data string can be loaded directly.
  61825. * @param data string contianing the file data
  61826. * @returns if the data can be loaded directly
  61827. */
  61828. canDirectLoad(data: string): boolean;
  61829. /**
  61830. * Rewrites a url by combining a root url and response url.
  61831. */
  61832. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  61833. /**
  61834. * Instantiates a glTF file loader plugin.
  61835. * @returns the created plugin
  61836. */
  61837. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  61838. /**
  61839. * The loader state or null if the loader is not active.
  61840. */
  61841. readonly loaderState: Nullable<GLTFLoaderState>;
  61842. /**
  61843. * Returns a promise that resolves when the asset is completely loaded.
  61844. * @returns a promise that resolves when the asset is completely loaded.
  61845. */
  61846. whenCompleteAsync(): Promise<void>;
  61847. private _parseAsync;
  61848. private _validateAsync;
  61849. private _getLoader;
  61850. private _unpackBinary;
  61851. private _unpackBinaryV1;
  61852. private _unpackBinaryV2;
  61853. private static _parseVersion;
  61854. private static _compareVersion;
  61855. private static _decodeBufferToText;
  61856. private static readonly _logSpaces;
  61857. private _logIndentLevel;
  61858. private _loggingEnabled;
  61859. /** @hidden */ private _log: (message: string) => void;
  61860. /** @hidden */ private _logOpen(message: string): void;
  61861. /** @hidden */ private _logClose(): void;
  61862. private _logEnabled;
  61863. private _logDisabled;
  61864. private _capturePerformanceCounters;
  61865. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  61866. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  61867. private _startPerformanceCounterEnabled;
  61868. private _startPerformanceCounterDisabled;
  61869. private _endPerformanceCounterEnabled;
  61870. private _endPerformanceCounterDisabled;
  61871. }
  61872. }
  61873. declare module BABYLON.GLTF1 {
  61874. /**
  61875. * Enums
  61876. * @hidden
  61877. */
  61878. export enum EComponentType {
  61879. BYTE = 5120,
  61880. UNSIGNED_BYTE = 5121,
  61881. SHORT = 5122,
  61882. UNSIGNED_SHORT = 5123,
  61883. FLOAT = 5126
  61884. }
  61885. /** @hidden */
  61886. export enum EShaderType {
  61887. FRAGMENT = 35632,
  61888. VERTEX = 35633
  61889. }
  61890. /** @hidden */
  61891. export enum EParameterType {
  61892. BYTE = 5120,
  61893. UNSIGNED_BYTE = 5121,
  61894. SHORT = 5122,
  61895. UNSIGNED_SHORT = 5123,
  61896. INT = 5124,
  61897. UNSIGNED_INT = 5125,
  61898. FLOAT = 5126,
  61899. FLOAT_VEC2 = 35664,
  61900. FLOAT_VEC3 = 35665,
  61901. FLOAT_VEC4 = 35666,
  61902. INT_VEC2 = 35667,
  61903. INT_VEC3 = 35668,
  61904. INT_VEC4 = 35669,
  61905. BOOL = 35670,
  61906. BOOL_VEC2 = 35671,
  61907. BOOL_VEC3 = 35672,
  61908. BOOL_VEC4 = 35673,
  61909. FLOAT_MAT2 = 35674,
  61910. FLOAT_MAT3 = 35675,
  61911. FLOAT_MAT4 = 35676,
  61912. SAMPLER_2D = 35678
  61913. }
  61914. /** @hidden */
  61915. export enum ETextureWrapMode {
  61916. CLAMP_TO_EDGE = 33071,
  61917. MIRRORED_REPEAT = 33648,
  61918. REPEAT = 10497
  61919. }
  61920. /** @hidden */
  61921. export enum ETextureFilterType {
  61922. NEAREST = 9728,
  61923. LINEAR = 9728,
  61924. NEAREST_MIPMAP_NEAREST = 9984,
  61925. LINEAR_MIPMAP_NEAREST = 9985,
  61926. NEAREST_MIPMAP_LINEAR = 9986,
  61927. LINEAR_MIPMAP_LINEAR = 9987
  61928. }
  61929. /** @hidden */
  61930. export enum ETextureFormat {
  61931. ALPHA = 6406,
  61932. RGB = 6407,
  61933. RGBA = 6408,
  61934. LUMINANCE = 6409,
  61935. LUMINANCE_ALPHA = 6410
  61936. }
  61937. /** @hidden */
  61938. export enum ECullingType {
  61939. FRONT = 1028,
  61940. BACK = 1029,
  61941. FRONT_AND_BACK = 1032
  61942. }
  61943. /** @hidden */
  61944. export enum EBlendingFunction {
  61945. ZERO = 0,
  61946. ONE = 1,
  61947. SRC_COLOR = 768,
  61948. ONE_MINUS_SRC_COLOR = 769,
  61949. DST_COLOR = 774,
  61950. ONE_MINUS_DST_COLOR = 775,
  61951. SRC_ALPHA = 770,
  61952. ONE_MINUS_SRC_ALPHA = 771,
  61953. DST_ALPHA = 772,
  61954. ONE_MINUS_DST_ALPHA = 773,
  61955. CONSTANT_COLOR = 32769,
  61956. ONE_MINUS_CONSTANT_COLOR = 32770,
  61957. CONSTANT_ALPHA = 32771,
  61958. ONE_MINUS_CONSTANT_ALPHA = 32772,
  61959. SRC_ALPHA_SATURATE = 776
  61960. }
  61961. /** @hidden */
  61962. export interface IGLTFProperty {
  61963. extensions?: {
  61964. [key: string]: any;
  61965. };
  61966. extras?: Object;
  61967. }
  61968. /** @hidden */
  61969. export interface IGLTFChildRootProperty extends IGLTFProperty {
  61970. name?: string;
  61971. }
  61972. /** @hidden */
  61973. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  61974. bufferView: string;
  61975. byteOffset: number;
  61976. byteStride: number;
  61977. count: number;
  61978. type: string;
  61979. componentType: EComponentType;
  61980. max?: number[];
  61981. min?: number[];
  61982. name?: string;
  61983. }
  61984. /** @hidden */
  61985. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  61986. buffer: string;
  61987. byteOffset: number;
  61988. byteLength: number;
  61989. byteStride: number;
  61990. target?: number;
  61991. }
  61992. /** @hidden */
  61993. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  61994. uri: string;
  61995. byteLength?: number;
  61996. type?: string;
  61997. }
  61998. /** @hidden */
  61999. export interface IGLTFShader extends IGLTFChildRootProperty {
  62000. uri: string;
  62001. type: EShaderType;
  62002. }
  62003. /** @hidden */
  62004. export interface IGLTFProgram extends IGLTFChildRootProperty {
  62005. attributes: string[];
  62006. fragmentShader: string;
  62007. vertexShader: string;
  62008. }
  62009. /** @hidden */
  62010. export interface IGLTFTechniqueParameter {
  62011. type: number;
  62012. count?: number;
  62013. semantic?: string;
  62014. node?: string;
  62015. value?: number | boolean | string | Array<any>;
  62016. source?: string;
  62017. babylonValue?: any;
  62018. }
  62019. /** @hidden */
  62020. export interface IGLTFTechniqueCommonProfile {
  62021. lightingModel: string;
  62022. texcoordBindings: Object;
  62023. parameters?: Array<any>;
  62024. }
  62025. /** @hidden */
  62026. export interface IGLTFTechniqueStatesFunctions {
  62027. blendColor?: number[];
  62028. blendEquationSeparate?: number[];
  62029. blendFuncSeparate?: number[];
  62030. colorMask: boolean[];
  62031. cullFace: number[];
  62032. }
  62033. /** @hidden */
  62034. export interface IGLTFTechniqueStates {
  62035. enable: number[];
  62036. functions: IGLTFTechniqueStatesFunctions;
  62037. }
  62038. /** @hidden */
  62039. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  62040. parameters: {
  62041. [key: string]: IGLTFTechniqueParameter;
  62042. };
  62043. program: string;
  62044. attributes: {
  62045. [key: string]: string;
  62046. };
  62047. uniforms: {
  62048. [key: string]: string;
  62049. };
  62050. states: IGLTFTechniqueStates;
  62051. }
  62052. /** @hidden */
  62053. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  62054. technique?: string;
  62055. values: string[];
  62056. }
  62057. /** @hidden */
  62058. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  62059. attributes: {
  62060. [key: string]: string;
  62061. };
  62062. indices: string;
  62063. material: string;
  62064. mode?: number;
  62065. }
  62066. /** @hidden */
  62067. export interface IGLTFMesh extends IGLTFChildRootProperty {
  62068. primitives: IGLTFMeshPrimitive[];
  62069. }
  62070. /** @hidden */
  62071. export interface IGLTFImage extends IGLTFChildRootProperty {
  62072. uri: string;
  62073. }
  62074. /** @hidden */
  62075. export interface IGLTFSampler extends IGLTFChildRootProperty {
  62076. magFilter?: number;
  62077. minFilter?: number;
  62078. wrapS?: number;
  62079. wrapT?: number;
  62080. }
  62081. /** @hidden */
  62082. export interface IGLTFTexture extends IGLTFChildRootProperty {
  62083. sampler: string;
  62084. source: string;
  62085. format?: ETextureFormat;
  62086. internalFormat?: ETextureFormat;
  62087. target?: number;
  62088. type?: number;
  62089. babylonTexture?: Texture;
  62090. }
  62091. /** @hidden */
  62092. export interface IGLTFAmbienLight {
  62093. color?: number[];
  62094. }
  62095. /** @hidden */
  62096. export interface IGLTFDirectionalLight {
  62097. color?: number[];
  62098. }
  62099. /** @hidden */
  62100. export interface IGLTFPointLight {
  62101. color?: number[];
  62102. constantAttenuation?: number;
  62103. linearAttenuation?: number;
  62104. quadraticAttenuation?: number;
  62105. }
  62106. /** @hidden */
  62107. export interface IGLTFSpotLight {
  62108. color?: number[];
  62109. constantAttenuation?: number;
  62110. fallOfAngle?: number;
  62111. fallOffExponent?: number;
  62112. linearAttenuation?: number;
  62113. quadraticAttenuation?: number;
  62114. }
  62115. /** @hidden */
  62116. export interface IGLTFLight extends IGLTFChildRootProperty {
  62117. type: string;
  62118. }
  62119. /** @hidden */
  62120. export interface IGLTFCameraOrthographic {
  62121. xmag: number;
  62122. ymag: number;
  62123. zfar: number;
  62124. znear: number;
  62125. }
  62126. /** @hidden */
  62127. export interface IGLTFCameraPerspective {
  62128. aspectRatio: number;
  62129. yfov: number;
  62130. zfar: number;
  62131. znear: number;
  62132. }
  62133. /** @hidden */
  62134. export interface IGLTFCamera extends IGLTFChildRootProperty {
  62135. type: string;
  62136. }
  62137. /** @hidden */
  62138. export interface IGLTFAnimationChannelTarget {
  62139. id: string;
  62140. path: string;
  62141. }
  62142. /** @hidden */
  62143. export interface IGLTFAnimationChannel {
  62144. sampler: string;
  62145. target: IGLTFAnimationChannelTarget;
  62146. }
  62147. /** @hidden */
  62148. export interface IGLTFAnimationSampler {
  62149. input: string;
  62150. output: string;
  62151. interpolation?: string;
  62152. }
  62153. /** @hidden */
  62154. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  62155. channels?: IGLTFAnimationChannel[];
  62156. parameters?: {
  62157. [key: string]: string;
  62158. };
  62159. samplers?: {
  62160. [key: string]: IGLTFAnimationSampler;
  62161. };
  62162. }
  62163. /** @hidden */
  62164. export interface IGLTFNodeInstanceSkin {
  62165. skeletons: string[];
  62166. skin: string;
  62167. meshes: string[];
  62168. }
  62169. /** @hidden */
  62170. export interface IGLTFSkins extends IGLTFChildRootProperty {
  62171. bindShapeMatrix: number[];
  62172. inverseBindMatrices: string;
  62173. jointNames: string[];
  62174. babylonSkeleton?: Skeleton;
  62175. }
  62176. /** @hidden */
  62177. export interface IGLTFNode extends IGLTFChildRootProperty {
  62178. camera?: string;
  62179. children: string[];
  62180. skin?: string;
  62181. jointName?: string;
  62182. light?: string;
  62183. matrix: number[];
  62184. mesh?: string;
  62185. meshes?: string[];
  62186. rotation?: number[];
  62187. scale?: number[];
  62188. translation?: number[];
  62189. babylonNode?: Node;
  62190. }
  62191. /** @hidden */
  62192. export interface IGLTFScene extends IGLTFChildRootProperty {
  62193. nodes: string[];
  62194. }
  62195. /** @hidden */
  62196. export interface IGLTFRuntime {
  62197. extensions: {
  62198. [key: string]: any;
  62199. };
  62200. accessors: {
  62201. [key: string]: IGLTFAccessor;
  62202. };
  62203. buffers: {
  62204. [key: string]: IGLTFBuffer;
  62205. };
  62206. bufferViews: {
  62207. [key: string]: IGLTFBufferView;
  62208. };
  62209. meshes: {
  62210. [key: string]: IGLTFMesh;
  62211. };
  62212. lights: {
  62213. [key: string]: IGLTFLight;
  62214. };
  62215. cameras: {
  62216. [key: string]: IGLTFCamera;
  62217. };
  62218. nodes: {
  62219. [key: string]: IGLTFNode;
  62220. };
  62221. images: {
  62222. [key: string]: IGLTFImage;
  62223. };
  62224. textures: {
  62225. [key: string]: IGLTFTexture;
  62226. };
  62227. shaders: {
  62228. [key: string]: IGLTFShader;
  62229. };
  62230. programs: {
  62231. [key: string]: IGLTFProgram;
  62232. };
  62233. samplers: {
  62234. [key: string]: IGLTFSampler;
  62235. };
  62236. techniques: {
  62237. [key: string]: IGLTFTechnique;
  62238. };
  62239. materials: {
  62240. [key: string]: IGLTFMaterial;
  62241. };
  62242. animations: {
  62243. [key: string]: IGLTFAnimation;
  62244. };
  62245. skins: {
  62246. [key: string]: IGLTFSkins;
  62247. };
  62248. currentScene?: Object;
  62249. scenes: {
  62250. [key: string]: IGLTFScene;
  62251. };
  62252. extensionsUsed: string[];
  62253. extensionsRequired?: string[];
  62254. buffersCount: number;
  62255. shaderscount: number;
  62256. scene: Scene;
  62257. rootUrl: string;
  62258. loadedBufferCount: number;
  62259. loadedBufferViews: {
  62260. [name: string]: ArrayBufferView;
  62261. };
  62262. loadedShaderCount: number;
  62263. importOnlyMeshes: boolean;
  62264. importMeshesNames?: string[];
  62265. dummyNodes: Node[];
  62266. }
  62267. /** @hidden */
  62268. export interface INodeToRoot {
  62269. bone: Bone;
  62270. node: IGLTFNode;
  62271. id: string;
  62272. }
  62273. /** @hidden */
  62274. export interface IJointNode {
  62275. node: IGLTFNode;
  62276. id: string;
  62277. }
  62278. }
  62279. declare module BABYLON.GLTF1 {
  62280. /**
  62281. * Utils functions for GLTF
  62282. * @hidden
  62283. */
  62284. export class GLTFUtils {
  62285. /**
  62286. * Sets the given "parameter" matrix
  62287. * @param scene: the Scene object
  62288. * @param source: the source node where to pick the matrix
  62289. * @param parameter: the GLTF technique parameter
  62290. * @param uniformName: the name of the shader's uniform
  62291. * @param shaderMaterial: the shader material
  62292. */
  62293. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  62294. /**
  62295. * Sets the given "parameter" matrix
  62296. * @param shaderMaterial: the shader material
  62297. * @param uniform: the name of the shader's uniform
  62298. * @param value: the value of the uniform
  62299. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  62300. */
  62301. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  62302. /**
  62303. * Returns the wrap mode of the texture
  62304. * @param mode: the mode value
  62305. */
  62306. static GetWrapMode(mode: number): number;
  62307. /**
  62308. * Returns the byte stride giving an accessor
  62309. * @param accessor: the GLTF accessor objet
  62310. */
  62311. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  62312. /**
  62313. * Returns the texture filter mode giving a mode value
  62314. * @param mode: the filter mode value
  62315. */
  62316. static GetTextureFilterMode(mode: number): ETextureFilterType;
  62317. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  62318. /**
  62319. * Returns a buffer from its accessor
  62320. * @param gltfRuntime: the GLTF runtime
  62321. * @param accessor: the GLTF accessor
  62322. */
  62323. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  62324. /**
  62325. * Decodes a buffer view into a string
  62326. * @param view: the buffer view
  62327. */
  62328. static DecodeBufferToText(view: ArrayBufferView): string;
  62329. /**
  62330. * Returns the default material of gltf. Related to
  62331. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  62332. * @param scene: the Babylon.js scene
  62333. */
  62334. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  62335. private static _DefaultMaterial;
  62336. }
  62337. }
  62338. declare module BABYLON.GLTF1 {
  62339. /**
  62340. * Implementation of the base glTF spec
  62341. * @hidden
  62342. */
  62343. export class GLTFLoaderBase {
  62344. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  62345. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  62346. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  62347. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  62348. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  62349. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  62350. }
  62351. /**
  62352. * glTF V1 Loader
  62353. * @hidden
  62354. */
  62355. export class GLTFLoader implements IGLTFLoader {
  62356. static Extensions: {
  62357. [name: string]: GLTFLoaderExtension;
  62358. };
  62359. static RegisterExtension(extension: GLTFLoaderExtension): void;
  62360. state: Nullable<GLTFLoaderState>;
  62361. dispose(): void;
  62362. private _importMeshAsync;
  62363. /**
  62364. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  62365. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  62366. * @param scene the scene the meshes should be added to
  62367. * @param data gltf data containing information of the meshes in a loaded file
  62368. * @param rootUrl root url to load from
  62369. * @param onProgress event that fires when loading progress has occured
  62370. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  62371. */
  62372. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  62373. meshes: AbstractMesh[];
  62374. particleSystems: IParticleSystem[];
  62375. skeletons: Skeleton[];
  62376. animationGroups: AnimationGroup[];
  62377. }>;
  62378. private _loadAsync;
  62379. /**
  62380. * Imports all objects from a loaded gltf file and adds them to the scene
  62381. * @param scene the scene the objects should be added to
  62382. * @param data gltf data containing information of the meshes in a loaded file
  62383. * @param rootUrl root url to load from
  62384. * @param onProgress event that fires when loading progress has occured
  62385. * @returns a promise which completes when objects have been loaded to the scene
  62386. */
  62387. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  62388. private _loadShadersAsync;
  62389. private _loadBuffersAsync;
  62390. private _createNodes;
  62391. }
  62392. /** @hidden */
  62393. export abstract class GLTFLoaderExtension {
  62394. private _name;
  62395. constructor(name: string);
  62396. readonly name: string;
  62397. /**
  62398. * Defines an override for loading the runtime
  62399. * Return true to stop further extensions from loading the runtime
  62400. */
  62401. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  62402. /**
  62403. * Defines an onverride for creating gltf runtime
  62404. * Return true to stop further extensions from creating the runtime
  62405. */
  62406. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  62407. /**
  62408. * Defines an override for loading buffers
  62409. * Return true to stop further extensions from loading this buffer
  62410. */
  62411. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  62412. /**
  62413. * Defines an override for loading texture buffers
  62414. * Return true to stop further extensions from loading this texture data
  62415. */
  62416. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  62417. /**
  62418. * Defines an override for creating textures
  62419. * Return true to stop further extensions from loading this texture
  62420. */
  62421. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  62422. /**
  62423. * Defines an override for loading shader strings
  62424. * Return true to stop further extensions from loading this shader data
  62425. */
  62426. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  62427. /**
  62428. * Defines an override for loading materials
  62429. * Return true to stop further extensions from loading this material
  62430. */
  62431. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  62432. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  62433. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  62434. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  62435. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  62436. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  62437. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  62438. private static LoadTextureBufferAsync;
  62439. private static CreateTextureAsync;
  62440. private static ApplyExtensions;
  62441. }
  62442. }
  62443. declare module BABYLON.GLTF1 {
  62444. /** @hidden */
  62445. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  62446. private _bin;
  62447. constructor();
  62448. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  62449. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  62450. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  62451. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  62452. }
  62453. }
  62454. declare module BABYLON.GLTF1 {
  62455. /** @hidden */
  62456. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  62457. constructor();
  62458. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  62459. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  62460. private _loadTexture;
  62461. }
  62462. }
  62463. declare module BABYLON.GLTF2.Loader {
  62464. /**
  62465. * Loader interface with an index field.
  62466. */
  62467. export interface IArrayItem {
  62468. /**
  62469. * The index of this item in the array.
  62470. */
  62471. index: number;
  62472. }
  62473. /**
  62474. * Loader interface with additional members.
  62475. */
  62476. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  62477. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62478. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  62479. }
  62480. /**
  62481. * Loader interface with additional members.
  62482. */
  62483. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  62484. }
  62485. /** @hidden */
  62486. export interface _IAnimationSamplerData {
  62487. input: Float32Array;
  62488. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  62489. output: Float32Array;
  62490. }
  62491. /**
  62492. * Loader interface with additional members.
  62493. */
  62494. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  62495. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  62496. }
  62497. /**
  62498. * Loader interface with additional members.
  62499. */
  62500. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  62501. channels: IAnimationChannel[];
  62502. samplers: IAnimationSampler[];
  62503. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  62504. }
  62505. /**
  62506. * Loader interface with additional members.
  62507. */
  62508. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  62509. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62510. }
  62511. /**
  62512. * Loader interface with additional members.
  62513. */
  62514. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  62515. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62516. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  62517. }
  62518. /**
  62519. * Loader interface with additional members.
  62520. */
  62521. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  62522. }
  62523. /**
  62524. * Loader interface with additional members.
  62525. */
  62526. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  62527. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  62528. }
  62529. /**
  62530. * Loader interface with additional members.
  62531. */
  62532. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  62533. }
  62534. /**
  62535. * Loader interface with additional members.
  62536. */
  62537. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  62538. }
  62539. /**
  62540. * Loader interface with additional members.
  62541. */
  62542. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  62543. baseColorTexture?: ITextureInfo;
  62544. metallicRoughnessTexture?: ITextureInfo;
  62545. }
  62546. /**
  62547. * Loader interface with additional members.
  62548. */
  62549. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  62550. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  62551. normalTexture?: IMaterialNormalTextureInfo;
  62552. occlusionTexture?: IMaterialOcclusionTextureInfo;
  62553. emissiveTexture?: ITextureInfo;
  62554. /** @hidden */ private _data?: {
  62555. [babylonDrawMode: number]: {
  62556. babylonMaterial: Material;
  62557. babylonMeshes: AbstractMesh[];
  62558. promise: Promise<void>;
  62559. };
  62560. };
  62561. }
  62562. /**
  62563. * Loader interface with additional members.
  62564. */
  62565. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  62566. primitives: IMeshPrimitive[];
  62567. }
  62568. /**
  62569. * Loader interface with additional members.
  62570. */
  62571. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  62572. /** @hidden */ private _instanceData?: {
  62573. babylonSourceMesh: Mesh;
  62574. promise: Promise<any>;
  62575. };
  62576. }
  62577. /**
  62578. * Loader interface with additional members.
  62579. */
  62580. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  62581. /**
  62582. * The parent glTF node.
  62583. */
  62584. parent?: INode;
  62585. /** @hidden */ private _babylonTransformNode?: TransformNode;
  62586. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  62587. /** @hidden */ private _babylonBones?: Bone[];
  62588. /** @hidden */ private _numMorphTargets?: number;
  62589. }
  62590. /** @hidden */
  62591. export interface _ISamplerData {
  62592. noMipMaps: boolean;
  62593. samplingMode: number;
  62594. wrapU: number;
  62595. wrapV: number;
  62596. }
  62597. /**
  62598. * Loader interface with additional members.
  62599. */
  62600. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  62601. /** @hidden */ private _data?: _ISamplerData;
  62602. }
  62603. /**
  62604. * Loader interface with additional members.
  62605. */
  62606. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  62607. }
  62608. /**
  62609. * Loader interface with additional members.
  62610. */
  62611. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  62612. /** @hidden */ private _data?: {
  62613. babylonSkeleton: Skeleton;
  62614. promise: Promise<void>;
  62615. };
  62616. }
  62617. /**
  62618. * Loader interface with additional members.
  62619. */
  62620. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  62621. }
  62622. /**
  62623. * Loader interface with additional members.
  62624. */
  62625. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  62626. }
  62627. /**
  62628. * Loader interface with additional members.
  62629. */
  62630. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  62631. accessors?: IAccessor[];
  62632. animations?: IAnimation[];
  62633. buffers?: IBuffer[];
  62634. bufferViews?: IBufferView[];
  62635. cameras?: ICamera[];
  62636. images?: IImage[];
  62637. materials?: IMaterial[];
  62638. meshes?: IMesh[];
  62639. nodes?: INode[];
  62640. samplers?: ISampler[];
  62641. scenes?: IScene[];
  62642. skins?: ISkin[];
  62643. textures?: ITexture[];
  62644. }
  62645. }
  62646. declare module BABYLON.GLTF2 {
  62647. /**
  62648. * Interface for a glTF loader extension.
  62649. */
  62650. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  62651. /**
  62652. * Called after the loader state changes to LOADING.
  62653. */
  62654. onLoading?(): void;
  62655. /**
  62656. * Called after the loader state changes to READY.
  62657. */
  62658. onReady?(): void;
  62659. /**
  62660. * Define this method to modify the default behavior when loading scenes.
  62661. * @param context The context when loading the asset
  62662. * @param scene The glTF scene property
  62663. * @returns A promise that resolves when the load is complete or null if not handled
  62664. */
  62665. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  62666. /**
  62667. * Define this method to modify the default behavior when loading nodes.
  62668. * @param context The context when loading the asset
  62669. * @param node The glTF node property
  62670. * @param assign A function called synchronously after parsing the glTF properties
  62671. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  62672. */
  62673. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  62674. /**
  62675. * Define this method to modify the default behavior when loading cameras.
  62676. * @param context The context when loading the asset
  62677. * @param camera The glTF camera property
  62678. * @param assign A function called synchronously after parsing the glTF properties
  62679. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  62680. */
  62681. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  62682. /**
  62683. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  62684. * @param context The context when loading the asset
  62685. * @param primitive The glTF mesh primitive property
  62686. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  62687. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  62688. /**
  62689. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  62690. * @param context The context when loading the asset
  62691. * @param name The mesh name when loading the asset
  62692. * @param node The glTF node when loading the asset
  62693. * @param mesh The glTF mesh when loading the asset
  62694. * @param primitive The glTF mesh primitive property
  62695. * @param assign A function called synchronously after parsing the glTF properties
  62696. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  62697. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  62698. /**
  62699. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  62700. * @param context The context when loading the asset
  62701. * @param material The glTF material property
  62702. * @param assign A function called synchronously after parsing the glTF properties
  62703. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  62704. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  62705. /**
  62706. * Define this method to modify the default behavior when creating materials.
  62707. * @param context The context when loading the asset
  62708. * @param material The glTF material property
  62709. * @param babylonDrawMode The draw mode for the Babylon material
  62710. * @returns The Babylon material or null if not handled
  62711. */
  62712. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  62713. /**
  62714. * Define this method to modify the default behavior when loading material properties.
  62715. * @param context The context when loading the asset
  62716. * @param material The glTF material property
  62717. * @param babylonMaterial The Babylon material
  62718. * @returns A promise that resolves when the load is complete or null if not handled
  62719. */
  62720. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  62721. /**
  62722. * Define this method to modify the default behavior when loading texture infos.
  62723. * @param context The context when loading the asset
  62724. * @param textureInfo The glTF texture info property
  62725. * @param assign A function called synchronously after parsing the glTF properties
  62726. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  62727. */
  62728. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  62729. /**
  62730. * Define this method to modify the default behavior when loading animations.
  62731. * @param context The context when loading the asset
  62732. * @param animation The glTF animation property
  62733. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  62734. */
  62735. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  62736. /**
  62737. * @hidden Define this method to modify the default behavior when loading skins.
  62738. * @param context The context when loading the asset
  62739. * @param node The glTF node property
  62740. * @param skin The glTF skin property
  62741. * @returns A promise that resolves when the load is complete or null if not handled
  62742. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  62743. /**
  62744. * @hidden Define this method to modify the default behavior when loading uris.
  62745. * @param context The context when loading the asset
  62746. * @param property The glTF property associated with the uri
  62747. * @param uri The uri to load
  62748. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  62749. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  62750. }
  62751. }
  62752. declare module BABYLON.GLTF2 {
  62753. /**
  62754. * Helper class for working with arrays when loading the glTF asset
  62755. */
  62756. export class ArrayItem {
  62757. /**
  62758. * Gets an item from the given array.
  62759. * @param context The context when loading the asset
  62760. * @param array The array to get the item from
  62761. * @param index The index to the array
  62762. * @returns The array item
  62763. */
  62764. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  62765. /**
  62766. * Assign an `index` field to each item of the given array.
  62767. * @param array The array of items
  62768. */
  62769. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  62770. }
  62771. /**
  62772. * The glTF 2.0 loader
  62773. */
  62774. export class GLTFLoader implements IGLTFLoader {
  62775. /** @hidden */ private _completePromises: Promise<any>[];
  62776. private _disposed;
  62777. private _parent;
  62778. private _state;
  62779. private _extensions;
  62780. private _rootUrl;
  62781. private _fileName;
  62782. private _uniqueRootUrl;
  62783. private _gltf;
  62784. private _babylonScene;
  62785. private _rootBabylonMesh;
  62786. private _defaultBabylonMaterialData;
  62787. private _progressCallback?;
  62788. private _requests;
  62789. private static readonly _DefaultSampler;
  62790. private static _ExtensionNames;
  62791. private static _ExtensionFactories;
  62792. /**
  62793. * Registers a loader extension.
  62794. * @param name The name of the loader extension.
  62795. * @param factory The factory function that creates the loader extension.
  62796. */
  62797. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  62798. /**
  62799. * Unregisters a loader extension.
  62800. * @param name The name of the loader extenion.
  62801. * @returns A boolean indicating whether the extension has been unregistered
  62802. */
  62803. static UnregisterExtension(name: string): boolean;
  62804. /**
  62805. * Gets the loader state.
  62806. */
  62807. readonly state: Nullable<GLTFLoaderState>;
  62808. /**
  62809. * The glTF object parsed from the JSON.
  62810. */
  62811. readonly gltf: IGLTF;
  62812. /**
  62813. * The Babylon scene when loading the asset.
  62814. */
  62815. readonly babylonScene: Scene;
  62816. /**
  62817. * The root Babylon mesh when loading the asset.
  62818. */
  62819. readonly rootBabylonMesh: Mesh;
  62820. /** @hidden */
  62821. constructor(parent: GLTFFileLoader);
  62822. /** @hidden */
  62823. dispose(): void;
  62824. /** @hidden */
  62825. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  62826. meshes: AbstractMesh[];
  62827. particleSystems: IParticleSystem[];
  62828. skeletons: Skeleton[];
  62829. animationGroups: AnimationGroup[];
  62830. }>;
  62831. /** @hidden */
  62832. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  62833. private _loadAsync;
  62834. private _loadData;
  62835. private _setupData;
  62836. private _loadExtensions;
  62837. private _checkExtensions;
  62838. private _setState;
  62839. private _createRootNode;
  62840. /**
  62841. * Loads a glTF scene.
  62842. * @param context The context when loading the asset
  62843. * @param scene The glTF scene property
  62844. * @returns A promise that resolves when the load is complete
  62845. */
  62846. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  62847. private _forEachPrimitive;
  62848. private _getMeshes;
  62849. private _getSkeletons;
  62850. private _getAnimationGroups;
  62851. private _startAnimations;
  62852. /**
  62853. * Loads a glTF node.
  62854. * @param context The context when loading the asset
  62855. * @param node The glTF node property
  62856. * @param assign A function called synchronously after parsing the glTF properties
  62857. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  62858. */
  62859. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  62860. private _loadMeshAsync;
  62861. /**
  62862. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  62863. * @param context The context when loading the asset
  62864. * @param name The mesh name when loading the asset
  62865. * @param node The glTF node when loading the asset
  62866. * @param mesh The glTF mesh when loading the asset
  62867. * @param primitive The glTF mesh primitive property
  62868. * @param assign A function called synchronously after parsing the glTF properties
  62869. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  62870. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  62871. private _loadVertexDataAsync;
  62872. private _createMorphTargets;
  62873. private _loadMorphTargetsAsync;
  62874. private _loadMorphTargetVertexDataAsync;
  62875. private static _LoadTransform;
  62876. private _loadSkinAsync;
  62877. private _loadBones;
  62878. private _loadBone;
  62879. private _loadSkinInverseBindMatricesDataAsync;
  62880. private _updateBoneMatrices;
  62881. private _getNodeMatrix;
  62882. /**
  62883. * Loads a glTF camera.
  62884. * @param context The context when loading the asset
  62885. * @param camera The glTF camera property
  62886. * @param assign A function called synchronously after parsing the glTF properties
  62887. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  62888. */
  62889. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  62890. private _loadAnimationsAsync;
  62891. /**
  62892. * Loads a glTF animation.
  62893. * @param context The context when loading the asset
  62894. * @param animation The glTF animation property
  62895. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  62896. */
  62897. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  62898. /**
  62899. * @hidden Loads a glTF animation channel.
  62900. * @param context The context when loading the asset
  62901. * @param animationContext The context of the animation when loading the asset
  62902. * @param animation The glTF animation property
  62903. * @param channel The glTF animation channel property
  62904. * @param babylonAnimationGroup The babylon animation group property
  62905. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  62906. * @returns A void promise when the channel load is complete
  62907. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  62908. private _loadAnimationSamplerAsync;
  62909. private _loadBufferAsync;
  62910. /**
  62911. * Loads a glTF buffer view.
  62912. * @param context The context when loading the asset
  62913. * @param bufferView The glTF buffer view property
  62914. * @returns A promise that resolves with the loaded data when the load is complete
  62915. */
  62916. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  62917. private _loadIndicesAccessorAsync;
  62918. private _loadFloatAccessorAsync;
  62919. private _loadVertexBufferViewAsync;
  62920. private _loadVertexAccessorAsync;
  62921. private _loadMaterialMetallicRoughnessPropertiesAsync;
  62922. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  62923. private _createDefaultMaterial;
  62924. /**
  62925. * Creates a Babylon material from a glTF material.
  62926. * @param context The context when loading the asset
  62927. * @param material The glTF material property
  62928. * @param babylonDrawMode The draw mode for the Babylon material
  62929. * @returns The Babylon material
  62930. */
  62931. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  62932. /**
  62933. * Loads properties from a glTF material into a Babylon material.
  62934. * @param context The context when loading the asset
  62935. * @param material The glTF material property
  62936. * @param babylonMaterial The Babylon material
  62937. * @returns A promise that resolves when the load is complete
  62938. */
  62939. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  62940. /**
  62941. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  62942. * @param context The context when loading the asset
  62943. * @param material The glTF material property
  62944. * @param babylonMaterial The Babylon material
  62945. * @returns A promise that resolves when the load is complete
  62946. */
  62947. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  62948. /**
  62949. * Loads the alpha properties from a glTF material into a Babylon material.
  62950. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  62951. * @param context The context when loading the asset
  62952. * @param material The glTF material property
  62953. * @param babylonMaterial The Babylon material
  62954. */
  62955. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  62956. /**
  62957. * Loads a glTF texture info.
  62958. * @param context The context when loading the asset
  62959. * @param textureInfo The glTF texture info property
  62960. * @param assign A function called synchronously after parsing the glTF properties
  62961. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  62962. */
  62963. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  62964. private _loadTextureAsync;
  62965. private _loadSampler;
  62966. /**
  62967. * Loads a glTF image.
  62968. * @param context The context when loading the asset
  62969. * @param image The glTF image property
  62970. * @returns A promise that resolves with the loaded data when the load is complete
  62971. */
  62972. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  62973. /**
  62974. * Loads a glTF uri.
  62975. * @param context The context when loading the asset
  62976. * @param property The glTF property associated with the uri
  62977. * @param uri The base64 or relative uri
  62978. * @returns A promise that resolves with the loaded data when the load is complete
  62979. */
  62980. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  62981. private _onProgress;
  62982. /**
  62983. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  62984. * @param babylonObject the Babylon object with metadata
  62985. * @param pointer the JSON pointer
  62986. */
  62987. static AddPointerMetadata(babylonObject: {
  62988. metadata: any;
  62989. }, pointer: string): void;
  62990. private static _GetTextureWrapMode;
  62991. private static _GetTextureSamplingMode;
  62992. private static _GetTypedArray;
  62993. private static _GetNumComponents;
  62994. private static _ValidateUri;
  62995. private static _GetDrawMode;
  62996. private _compileMaterialsAsync;
  62997. private _compileShadowGeneratorsAsync;
  62998. private _forEachExtensions;
  62999. private _applyExtensions;
  63000. private _extensionsOnLoading;
  63001. private _extensionsOnReady;
  63002. private _extensionsLoadSceneAsync;
  63003. private _extensionsLoadNodeAsync;
  63004. private _extensionsLoadCameraAsync;
  63005. private _extensionsLoadVertexDataAsync;
  63006. private _extensionsLoadMeshPrimitiveAsync;
  63007. private _extensionsLoadMaterialAsync;
  63008. private _extensionsCreateMaterial;
  63009. private _extensionsLoadMaterialPropertiesAsync;
  63010. private _extensionsLoadTextureInfoAsync;
  63011. private _extensionsLoadAnimationAsync;
  63012. private _extensionsLoadSkinAsync;
  63013. private _extensionsLoadUriAsync;
  63014. /**
  63015. * Helper method called by a loader extension to load an glTF extension.
  63016. * @param context The context when loading the asset
  63017. * @param property The glTF property to load the extension from
  63018. * @param extensionName The name of the extension to load
  63019. * @param actionAsync The action to run
  63020. * @returns The promise returned by actionAsync or null if the extension does not exist
  63021. */
  63022. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63023. /**
  63024. * Helper method called by a loader extension to load a glTF extra.
  63025. * @param context The context when loading the asset
  63026. * @param property The glTF property to load the extra from
  63027. * @param extensionName The name of the extension to load
  63028. * @param actionAsync The action to run
  63029. * @returns The promise returned by actionAsync or null if the extra does not exist
  63030. */
  63031. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  63032. /**
  63033. * Increments the indentation level and logs a message.
  63034. * @param message The message to log
  63035. */
  63036. logOpen(message: string): void;
  63037. /**
  63038. * Decrements the indentation level.
  63039. */
  63040. logClose(): void;
  63041. /**
  63042. * Logs a message
  63043. * @param message The message to log
  63044. */
  63045. log(message: string): void;
  63046. /**
  63047. * Starts a performance counter.
  63048. * @param counterName The name of the performance counter
  63049. */
  63050. startPerformanceCounter(counterName: string): void;
  63051. /**
  63052. * Ends a performance counter.
  63053. * @param counterName The name of the performance counter
  63054. */
  63055. endPerformanceCounter(counterName: string): void;
  63056. }
  63057. }
  63058. declare module BABYLON.GLTF2.Loader.Extensions {
  63059. /**
  63060. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  63061. */
  63062. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  63063. /** The name of this extension. */
  63064. readonly name: string;
  63065. /** Defines whether this extension is enabled. */
  63066. enabled: boolean;
  63067. private _loader;
  63068. private _lights?;
  63069. /** @hidden */
  63070. constructor(loader: GLTFLoader);
  63071. /** @hidden */
  63072. dispose(): void;
  63073. /** @hidden */
  63074. onLoading(): void;
  63075. /** @hidden */
  63076. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  63077. private _loadLightAsync;
  63078. }
  63079. }
  63080. declare module BABYLON.GLTF2.Loader.Extensions {
  63081. /**
  63082. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  63083. */
  63084. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  63085. /** The name of this extension. */
  63086. readonly name: string;
  63087. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  63088. dracoCompression?: DracoCompression;
  63089. /** Defines whether this extension is enabled. */
  63090. enabled: boolean;
  63091. private _loader;
  63092. /** @hidden */
  63093. constructor(loader: GLTFLoader);
  63094. /** @hidden */
  63095. dispose(): void;
  63096. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  63097. }
  63098. }
  63099. declare module BABYLON.GLTF2.Loader.Extensions {
  63100. /**
  63101. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  63102. */
  63103. export class KHR_lights implements IGLTFLoaderExtension {
  63104. /** The name of this extension. */
  63105. readonly name: string;
  63106. /** Defines whether this extension is enabled. */
  63107. enabled: boolean;
  63108. private _loader;
  63109. private _lights?;
  63110. /** @hidden */
  63111. constructor(loader: GLTFLoader);
  63112. /** @hidden */
  63113. dispose(): void;
  63114. /** @hidden */
  63115. onLoading(): void;
  63116. /** @hidden */
  63117. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63118. }
  63119. }
  63120. declare module BABYLON.GLTF2.Loader.Extensions {
  63121. /**
  63122. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  63123. */
  63124. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  63125. /** The name of this extension. */
  63126. readonly name: string;
  63127. /** Defines whether this extension is enabled. */
  63128. enabled: boolean;
  63129. private _loader;
  63130. /** @hidden */
  63131. constructor(loader: GLTFLoader);
  63132. /** @hidden */
  63133. dispose(): void;
  63134. /** @hidden */
  63135. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63136. private _loadSpecularGlossinessPropertiesAsync;
  63137. }
  63138. }
  63139. declare module BABYLON.GLTF2.Loader.Extensions {
  63140. /**
  63141. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  63142. */
  63143. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  63144. /** The name of this extension. */
  63145. readonly name: string;
  63146. /** Defines whether this extension is enabled. */
  63147. enabled: boolean;
  63148. private _loader;
  63149. /** @hidden */
  63150. constructor(loader: GLTFLoader);
  63151. /** @hidden */
  63152. dispose(): void;
  63153. /** @hidden */
  63154. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63155. private _loadUnlitPropertiesAsync;
  63156. }
  63157. }
  63158. declare module BABYLON.GLTF2.Loader.Extensions {
  63159. /**
  63160. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  63161. */
  63162. export class KHR_texture_transform implements IGLTFLoaderExtension {
  63163. /** The name of this extension. */
  63164. readonly name: string;
  63165. /** Defines whether this extension is enabled. */
  63166. enabled: boolean;
  63167. private _loader;
  63168. /** @hidden */
  63169. constructor(loader: GLTFLoader);
  63170. /** @hidden */
  63171. dispose(): void;
  63172. /** @hidden */
  63173. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  63174. }
  63175. }
  63176. declare module BABYLON.GLTF2.Loader.Extensions {
  63177. /**
  63178. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  63179. */
  63180. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  63181. /** The name of this extension. */
  63182. readonly name: string;
  63183. /** Defines whether this extension is enabled. */
  63184. enabled: boolean;
  63185. private _loader;
  63186. private _clips;
  63187. private _emitters;
  63188. /** @hidden */
  63189. constructor(loader: GLTFLoader);
  63190. /** @hidden */
  63191. dispose(): void;
  63192. /** @hidden */
  63193. onLoading(): void;
  63194. /** @hidden */
  63195. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  63196. /** @hidden */
  63197. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63198. /** @hidden */
  63199. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  63200. private _loadClipAsync;
  63201. private _loadEmitterAsync;
  63202. private _getEventAction;
  63203. private _loadAnimationEventAsync;
  63204. }
  63205. }
  63206. declare module BABYLON.GLTF2.Loader.Extensions {
  63207. /**
  63208. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  63209. */
  63210. export class MSFT_lod implements IGLTFLoaderExtension {
  63211. /** The name of this extension. */
  63212. readonly name: string;
  63213. /** Defines whether this extension is enabled. */
  63214. enabled: boolean;
  63215. /**
  63216. * Maximum number of LODs to load, starting from the lowest LOD.
  63217. */
  63218. maxLODsToLoad: number;
  63219. /**
  63220. * Observable raised when all node LODs of one level are loaded.
  63221. * The event data is the index of the loaded LOD starting from zero.
  63222. * Dispose the loader to cancel the loading of the next level of LODs.
  63223. */
  63224. onNodeLODsLoadedObservable: Observable<number>;
  63225. /**
  63226. * Observable raised when all material LODs of one level are loaded.
  63227. * The event data is the index of the loaded LOD starting from zero.
  63228. * Dispose the loader to cancel the loading of the next level of LODs.
  63229. */
  63230. onMaterialLODsLoadedObservable: Observable<number>;
  63231. private _loader;
  63232. private _nodeIndexLOD;
  63233. private _nodeSignalLODs;
  63234. private _nodePromiseLODs;
  63235. private _materialIndexLOD;
  63236. private _materialSignalLODs;
  63237. private _materialPromiseLODs;
  63238. /** @hidden */
  63239. constructor(loader: GLTFLoader);
  63240. /** @hidden */
  63241. dispose(): void;
  63242. /** @hidden */
  63243. onReady(): void;
  63244. /** @hidden */
  63245. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  63246. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  63247. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  63248. /**
  63249. * Gets an array of LOD properties from lowest to highest.
  63250. */
  63251. private _getLODs;
  63252. private _disposeUnusedMaterials;
  63253. }
  63254. }
  63255. declare module BABYLON.GLTF2.Loader.Extensions {
  63256. /** @hidden */
  63257. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  63258. readonly name: string;
  63259. enabled: boolean;
  63260. private _loader;
  63261. constructor(loader: GLTFLoader);
  63262. dispose(): void;
  63263. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63264. }
  63265. }
  63266. declare module BABYLON.GLTF2.Loader.Extensions {
  63267. /** @hidden */
  63268. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  63269. readonly name: string;
  63270. enabled: boolean;
  63271. private _loader;
  63272. constructor(loader: GLTFLoader);
  63273. dispose(): void;
  63274. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  63275. }
  63276. }
  63277. declare module BABYLON {
  63278. /**
  63279. * Class reading and parsing the MTL file bundled with the obj file.
  63280. */
  63281. export class MTLFileLoader {
  63282. /**
  63283. * All material loaded from the mtl will be set here
  63284. */
  63285. materials: StandardMaterial[];
  63286. /**
  63287. * This function will read the mtl file and create each material described inside
  63288. * This function could be improve by adding :
  63289. * -some component missing (Ni, Tf...)
  63290. * -including the specific options available
  63291. *
  63292. * @param scene defines the scene the material will be created in
  63293. * @param data defines the mtl data to parse
  63294. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  63295. */
  63296. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  63297. /**
  63298. * Gets the texture for the material.
  63299. *
  63300. * If the material is imported from input file,
  63301. * We sanitize the url to ensure it takes the textre from aside the material.
  63302. *
  63303. * @param rootUrl The root url to load from
  63304. * @param value The value stored in the mtl
  63305. * @return The Texture
  63306. */
  63307. private static _getTexture;
  63308. }
  63309. /**
  63310. * Options for loading OBJ/MTL files
  63311. */
  63312. type MeshLoadOptions = {
  63313. /**
  63314. * Defines if UVs are optimized by default during load.
  63315. */
  63316. OptimizeWithUV: boolean;
  63317. /**
  63318. * Defines custom scaling of UV coordinates of loaded meshes.
  63319. */
  63320. UVScaling: Vector2;
  63321. /**
  63322. * Invert model on y-axis (does a model scaling inversion)
  63323. */
  63324. InvertY: boolean;
  63325. /**
  63326. * Invert Y-Axis of referenced textures on load
  63327. */
  63328. InvertTextureY: boolean;
  63329. /**
  63330. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  63331. */
  63332. ImportVertexColors: boolean;
  63333. /**
  63334. * Compute the normals for the model, even if normals are present in the file.
  63335. */
  63336. ComputeNormals: boolean;
  63337. /**
  63338. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  63339. */
  63340. SkipMaterials: boolean;
  63341. /**
  63342. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  63343. */
  63344. MaterialLoadingFailsSilently: boolean;
  63345. };
  63346. /**
  63347. * OBJ file type loader.
  63348. * This is a babylon scene loader plugin.
  63349. */
  63350. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  63351. /**
  63352. * Defines if UVs are optimized by default during load.
  63353. */
  63354. static OPTIMIZE_WITH_UV: boolean;
  63355. /**
  63356. * Invert model on y-axis (does a model scaling inversion)
  63357. */
  63358. static INVERT_Y: boolean;
  63359. /**
  63360. * Invert Y-Axis of referenced textures on load
  63361. */
  63362. static INVERT_TEXTURE_Y: boolean;
  63363. /**
  63364. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  63365. */
  63366. static IMPORT_VERTEX_COLORS: boolean;
  63367. /**
  63368. * Compute the normals for the model, even if normals are present in the file.
  63369. */
  63370. static COMPUTE_NORMALS: boolean;
  63371. /**
  63372. * Defines custom scaling of UV coordinates of loaded meshes.
  63373. */
  63374. static UV_SCALING: Vector2;
  63375. /**
  63376. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  63377. */
  63378. static SKIP_MATERIALS: boolean;
  63379. /**
  63380. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  63381. *
  63382. * Defaults to true for backwards compatibility.
  63383. */
  63384. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  63385. /**
  63386. * Defines the name of the plugin.
  63387. */
  63388. name: string;
  63389. /**
  63390. * Defines the extension the plugin is able to load.
  63391. */
  63392. extensions: string;
  63393. /** @hidden */
  63394. obj: RegExp;
  63395. /** @hidden */
  63396. group: RegExp;
  63397. /** @hidden */
  63398. mtllib: RegExp;
  63399. /** @hidden */
  63400. usemtl: RegExp;
  63401. /** @hidden */
  63402. smooth: RegExp;
  63403. /** @hidden */
  63404. vertexPattern: RegExp;
  63405. /** @hidden */
  63406. normalPattern: RegExp;
  63407. /** @hidden */
  63408. uvPattern: RegExp;
  63409. /** @hidden */
  63410. facePattern1: RegExp;
  63411. /** @hidden */
  63412. facePattern2: RegExp;
  63413. /** @hidden */
  63414. facePattern3: RegExp;
  63415. /** @hidden */
  63416. facePattern4: RegExp;
  63417. /** @hidden */
  63418. facePattern5: RegExp;
  63419. private _meshLoadOptions;
  63420. /**
  63421. * Creates loader for .OBJ files
  63422. *
  63423. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  63424. */
  63425. constructor(meshLoadOptions?: MeshLoadOptions);
  63426. private static readonly currentMeshLoadOptions;
  63427. /**
  63428. * Calls synchronously the MTL file attached to this obj.
  63429. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  63430. * Without this function materials are not displayed in the first frame (but displayed after).
  63431. * In consequence it is impossible to get material information in your HTML file
  63432. *
  63433. * @param url The URL of the MTL file
  63434. * @param rootUrl
  63435. * @param onSuccess Callback function to be called when the MTL file is loaded
  63436. * @private
  63437. */
  63438. private _loadMTL;
  63439. /**
  63440. * Instantiates a OBJ file loader plugin.
  63441. * @returns the created plugin
  63442. */
  63443. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  63444. /**
  63445. * If the data string can be loaded directly.
  63446. *
  63447. * @param data string containing the file data
  63448. * @returns if the data can be loaded directly
  63449. */
  63450. canDirectLoad(data: string): boolean;
  63451. /**
  63452. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  63453. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  63454. * @param scene the scene the meshes should be added to
  63455. * @param data the OBJ data to load
  63456. * @param rootUrl root url to load from
  63457. * @param onProgress event that fires when loading progress has occured
  63458. * @param fileName Defines the name of the file to load
  63459. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  63460. */
  63461. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  63462. meshes: AbstractMesh[];
  63463. particleSystems: IParticleSystem[];
  63464. skeletons: Skeleton[];
  63465. animationGroups: AnimationGroup[];
  63466. }>;
  63467. /**
  63468. * Imports all objects from the loaded OBJ data and adds them to the scene
  63469. * @param scene the scene the objects should be added to
  63470. * @param data the OBJ data to load
  63471. * @param rootUrl root url to load from
  63472. * @param onProgress event that fires when loading progress has occured
  63473. * @param fileName Defines the name of the file to load
  63474. * @returns a promise which completes when objects have been loaded to the scene
  63475. */
  63476. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  63477. /**
  63478. * Load into an asset container.
  63479. * @param scene The scene to load into
  63480. * @param data The data to import
  63481. * @param rootUrl The root url for scene and resources
  63482. * @param onProgress The callback when the load progresses
  63483. * @param fileName Defines the name of the file to load
  63484. * @returns The loaded asset container
  63485. */
  63486. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  63487. /**
  63488. * Read the OBJ file and create an Array of meshes.
  63489. * Each mesh contains all information given by the OBJ and the MTL file.
  63490. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  63491. *
  63492. * @param meshesNames
  63493. * @param scene Scene The scene where are displayed the data
  63494. * @param data String The content of the obj file
  63495. * @param rootUrl String The path to the folder
  63496. * @returns Array<AbstractMesh>
  63497. * @private
  63498. */
  63499. private _parseSolid;
  63500. }
  63501. }
  63502. declare module BABYLON {
  63503. /**
  63504. * STL file type loader.
  63505. * This is a babylon scene loader plugin.
  63506. */
  63507. export class STLFileLoader implements ISceneLoaderPlugin {
  63508. /** @hidden */
  63509. solidPattern: RegExp;
  63510. /** @hidden */
  63511. facetsPattern: RegExp;
  63512. /** @hidden */
  63513. normalPattern: RegExp;
  63514. /** @hidden */
  63515. vertexPattern: RegExp;
  63516. /**
  63517. * Defines the name of the plugin.
  63518. */
  63519. name: string;
  63520. /**
  63521. * Defines the extensions the stl loader is able to load.
  63522. * force data to come in as an ArrayBuffer
  63523. * we'll convert to string if it looks like it's an ASCII .stl
  63524. */
  63525. extensions: ISceneLoaderPluginExtensions;
  63526. /**
  63527. * Import meshes into a scene.
  63528. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  63529. * @param scene The scene to import into
  63530. * @param data The data to import
  63531. * @param rootUrl The root url for scene and resources
  63532. * @param meshes The meshes array to import into
  63533. * @param particleSystems The particle systems array to import into
  63534. * @param skeletons The skeletons array to import into
  63535. * @param onError The callback when import fails
  63536. * @returns True if successful or false otherwise
  63537. */
  63538. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  63539. /**
  63540. * Load into a scene.
  63541. * @param scene The scene to load into
  63542. * @param data The data to import
  63543. * @param rootUrl The root url for scene and resources
  63544. * @param onError The callback when import fails
  63545. * @returns true if successful or false otherwise
  63546. */
  63547. load(scene: Scene, data: any, rootUrl: string): boolean;
  63548. /**
  63549. * Load into an asset container.
  63550. * @param scene The scene to load into
  63551. * @param data The data to import
  63552. * @param rootUrl The root url for scene and resources
  63553. * @param onError The callback when import fails
  63554. * @returns The loaded asset container
  63555. */
  63556. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  63557. private _isBinary;
  63558. private _parseBinary;
  63559. private _parseASCII;
  63560. }
  63561. }
  63562. declare module BABYLON {
  63563. /**
  63564. * Class for generating OBJ data from a Babylon scene.
  63565. */
  63566. export class OBJExport {
  63567. /**
  63568. * Exports the geometry of a Mesh array in .OBJ file format (text)
  63569. * @param mesh defines the list of meshes to serialize
  63570. * @param materials defines if materials should be exported
  63571. * @param matlibname defines the name of the associated mtl file
  63572. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  63573. * @returns the OBJ content
  63574. */
  63575. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  63576. /**
  63577. * Exports the material(s) of a mesh in .MTL file format (text)
  63578. * @param mesh defines the mesh to extract the material from
  63579. * @returns the mtl content
  63580. */
  63581. static MTL(mesh: Mesh): string;
  63582. }
  63583. }
  63584. declare module BABYLON {
  63585. /** @hidden */
  63586. export var __IGLTFExporterExtension: number;
  63587. /**
  63588. * Interface for extending the exporter
  63589. * @hidden
  63590. */
  63591. export interface IGLTFExporterExtension {
  63592. /**
  63593. * The name of this extension
  63594. */
  63595. readonly name: string;
  63596. /**
  63597. * Defines whether this extension is enabled
  63598. */
  63599. enabled: boolean;
  63600. /**
  63601. * Defines whether this extension is required
  63602. */
  63603. required: boolean;
  63604. }
  63605. }
  63606. declare module BABYLON.GLTF2.Exporter {
  63607. /** @hidden */
  63608. export var __IGLTFExporterExtensionV2: number;
  63609. /**
  63610. * Interface for a glTF exporter extension
  63611. * @hidden
  63612. */
  63613. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  63614. /**
  63615. * Define this method to modify the default behavior before exporting a texture
  63616. * @param context The context when loading the asset
  63617. * @param babylonTexture The glTF texture info property
  63618. * @param mimeType The mime-type of the generated image
  63619. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  63620. */
  63621. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  63622. /**
  63623. * Define this method to modify the default behavior when exporting texture info
  63624. * @param context The context when loading the asset
  63625. * @param meshPrimitive glTF mesh primitive
  63626. * @param babylonSubMesh Babylon submesh
  63627. * @param binaryWriter glTF serializer binary writer instance
  63628. * @returns nullable IMeshPrimitive promise
  63629. */
  63630. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  63631. /**
  63632. * Define this method to modify the default behavior when exporting a node
  63633. * @param context The context when exporting the node
  63634. * @param node glTF node
  63635. * @param babylonNode BabylonJS node
  63636. * @returns nullable INode promise
  63637. */
  63638. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  63639. /**
  63640. * Called after the exporter state changes to EXPORTING
  63641. */
  63642. onExporting?(): void;
  63643. }
  63644. }
  63645. declare module BABYLON.GLTF2.Exporter {
  63646. /**
  63647. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  63648. * @hidden
  63649. */
  63650. export class _GLTFMaterialExporter {
  63651. /**
  63652. * Represents the dielectric specular values for R, G and B
  63653. */
  63654. private static readonly _DielectricSpecular;
  63655. /**
  63656. * Allows the maximum specular power to be defined for material calculations
  63657. */
  63658. private static readonly _MaxSpecularPower;
  63659. /**
  63660. * Mapping to store textures
  63661. */
  63662. private _textureMap;
  63663. /**
  63664. * Numeric tolerance value
  63665. */
  63666. private static readonly _Epsilon;
  63667. /**
  63668. * Reference to the glTF Exporter
  63669. */
  63670. private _exporter;
  63671. constructor(exporter: _Exporter);
  63672. /**
  63673. * Specifies if two colors are approximately equal in value
  63674. * @param color1 first color to compare to
  63675. * @param color2 second color to compare to
  63676. * @param epsilon threshold value
  63677. */
  63678. private static FuzzyEquals;
  63679. /**
  63680. * Gets the materials from a Babylon scene and converts them to glTF materials
  63681. * @param scene babylonjs scene
  63682. * @param mimeType texture mime type
  63683. * @param images array of images
  63684. * @param textures array of textures
  63685. * @param materials array of materials
  63686. * @param imageData mapping of texture names to base64 textures
  63687. * @param hasTextureCoords specifies if texture coordinates are present on the material
  63688. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63689. /**
  63690. * Makes a copy of the glTF material without the texture parameters
  63691. * @param originalMaterial original glTF material
  63692. * @returns glTF material without texture parameters
  63693. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  63694. /**
  63695. * Specifies if the material has any texture parameters present
  63696. * @param material glTF Material
  63697. * @returns boolean specifying if texture parameters are present
  63698. */ private _hasTexturesPresent(material: IMaterial): boolean;
  63699. /**
  63700. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  63701. * @param babylonStandardMaterial
  63702. * @returns glTF Metallic Roughness Material representation
  63703. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  63704. /**
  63705. * Computes the metallic factor
  63706. * @param diffuse diffused value
  63707. * @param specular specular value
  63708. * @param oneMinusSpecularStrength one minus the specular strength
  63709. * @returns metallic value
  63710. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  63711. /**
  63712. * Gets the glTF alpha mode from the Babylon Material
  63713. * @param babylonMaterial Babylon Material
  63714. * @returns The Babylon alpha mode value
  63715. */ private _getAlphaMode(babylonMaterial: Material): MaterialAlphaMode;
  63716. /**
  63717. * Converts a Babylon Standard Material to a glTF Material
  63718. * @param babylonStandardMaterial BJS Standard Material
  63719. * @param mimeType mime type to use for the textures
  63720. * @param images array of glTF image interfaces
  63721. * @param textures array of glTF texture interfaces
  63722. * @param materials array of glTF material interfaces
  63723. * @param imageData map of image file name to data
  63724. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63725. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63726. /**
  63727. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  63728. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  63729. * @param mimeType mime type to use for the textures
  63730. * @param images array of glTF image interfaces
  63731. * @param textures array of glTF texture interfaces
  63732. * @param materials array of glTF material interfaces
  63733. * @param imageData map of image file name to data
  63734. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63735. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63736. /**
  63737. * Converts an image typed array buffer to a base64 image
  63738. * @param buffer typed array buffer
  63739. * @param width width of the image
  63740. * @param height height of the image
  63741. * @param mimeType mimetype of the image
  63742. * @returns base64 image string
  63743. */
  63744. private _createBase64FromCanvasAsync;
  63745. /**
  63746. * Generates a white texture based on the specified width and height
  63747. * @param width width of the texture in pixels
  63748. * @param height height of the texture in pixels
  63749. * @param scene babylonjs scene
  63750. * @returns white texture
  63751. */
  63752. private _createWhiteTexture;
  63753. /**
  63754. * 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
  63755. * @param texture1 first texture to resize
  63756. * @param texture2 second texture to resize
  63757. * @param scene babylonjs scene
  63758. * @returns resized textures or null
  63759. */
  63760. private _resizeTexturesToSameDimensions;
  63761. /**
  63762. * Converts an array of pixels to a Float32Array
  63763. * Throws an error if the pixel format is not supported
  63764. * @param pixels - array buffer containing pixel values
  63765. * @returns Float32 of pixels
  63766. */
  63767. private _convertPixelArrayToFloat32;
  63768. /**
  63769. * Convert Specular Glossiness Textures to Metallic Roughness
  63770. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  63771. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  63772. * @param diffuseTexture texture used to store diffuse information
  63773. * @param specularGlossinessTexture texture used to store specular and glossiness information
  63774. * @param factors specular glossiness material factors
  63775. * @param mimeType the mime type to use for the texture
  63776. * @returns pbr metallic roughness interface or null
  63777. */
  63778. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  63779. /**
  63780. * Converts specular glossiness material properties to metallic roughness
  63781. * @param specularGlossiness interface with specular glossiness material properties
  63782. * @returns interface with metallic roughness material properties
  63783. */
  63784. private _convertSpecularGlossinessToMetallicRoughness;
  63785. /**
  63786. * Calculates the surface reflectance, independent of lighting conditions
  63787. * @param color Color source to calculate brightness from
  63788. * @returns number representing the perceived brightness, or zero if color is undefined
  63789. */
  63790. private _getPerceivedBrightness;
  63791. /**
  63792. * Returns the maximum color component value
  63793. * @param color
  63794. * @returns maximum color component value, or zero if color is null or undefined
  63795. */
  63796. private _getMaxComponent;
  63797. /**
  63798. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  63799. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  63800. * @param mimeType mime type to use for the textures
  63801. * @param images array of glTF image interfaces
  63802. * @param textures array of glTF texture interfaces
  63803. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  63804. * @param imageData map of image file name to data
  63805. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63806. * @returns glTF PBR Metallic Roughness factors
  63807. */
  63808. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  63809. private _getGLTFTextureSampler;
  63810. private _getGLTFTextureWrapMode;
  63811. private _getGLTFTextureWrapModesSampler;
  63812. /**
  63813. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  63814. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  63815. * @param mimeType mime type to use for the textures
  63816. * @param images array of glTF image interfaces
  63817. * @param textures array of glTF texture interfaces
  63818. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  63819. * @param imageData map of image file name to data
  63820. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63821. * @returns glTF PBR Metallic Roughness factors
  63822. */
  63823. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  63824. /**
  63825. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  63826. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  63827. * @param mimeType mime type to use for the textures
  63828. * @param images array of glTF image interfaces
  63829. * @param textures array of glTF texture interfaces
  63830. * @param materials array of glTF material interfaces
  63831. * @param imageData map of image file name to data
  63832. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  63833. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  63834. private setMetallicRoughnessPbrMaterial;
  63835. private getPixelsFromTexture;
  63836. /**
  63837. * Extracts a texture from a Babylon texture into file data and glTF data
  63838. * @param babylonTexture Babylon texture to extract
  63839. * @param mimeType Mime Type of the babylonTexture
  63840. * @return glTF texture info, or null if the texture format is not supported
  63841. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  63842. /**
  63843. * Builds a texture from base64 string
  63844. * @param base64Texture base64 texture string
  63845. * @param baseTextureName Name to use for the texture
  63846. * @param mimeType image mime type for the texture
  63847. * @param images array of images
  63848. * @param textures array of textures
  63849. * @param imageData map of image data
  63850. * @returns glTF texture info, or null if the texture format is not supported
  63851. */
  63852. private _getTextureInfoFromBase64;
  63853. }
  63854. }
  63855. declare module BABYLON {
  63856. /**
  63857. * Class for holding and downloading glTF file data
  63858. */
  63859. export class GLTFData {
  63860. /**
  63861. * Object which contains the file name as the key and its data as the value
  63862. */
  63863. glTFFiles: {
  63864. [fileName: string]: string | Blob;
  63865. };
  63866. /**
  63867. * Initializes the glTF file object
  63868. */
  63869. constructor();
  63870. /**
  63871. * Downloads the glTF data as files based on their names and data
  63872. */
  63873. downloadFiles(): void;
  63874. }
  63875. }
  63876. declare module BABYLON {
  63877. /**
  63878. * Holds a collection of exporter options and parameters
  63879. */
  63880. export interface IExportOptions {
  63881. /**
  63882. * Function which indicates whether a babylon node should be exported or not
  63883. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  63884. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  63885. */
  63886. shouldExportNode?(node: Node): boolean;
  63887. /**
  63888. * The sample rate to bake animation curves
  63889. */
  63890. animationSampleRate?: number;
  63891. /**
  63892. * Begin serialization without waiting for the scene to be ready
  63893. */
  63894. exportWithoutWaitingForScene?: boolean;
  63895. }
  63896. /**
  63897. * Class for generating glTF data from a Babylon scene.
  63898. */
  63899. export class GLTF2Export {
  63900. /**
  63901. * Exports the geometry of the scene to .gltf file format asynchronously
  63902. * @param scene Babylon scene with scene hierarchy information
  63903. * @param filePrefix File prefix to use when generating the glTF file
  63904. * @param options Exporter options
  63905. * @returns Returns an object with a .gltf file and associates texture names
  63906. * as keys and their data and paths as values
  63907. */
  63908. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  63909. private static _PreExportAsync;
  63910. private static _PostExportAsync;
  63911. /**
  63912. * Exports the geometry of the scene to .glb file format asychronously
  63913. * @param scene Babylon scene with scene hierarchy information
  63914. * @param filePrefix File prefix to use when generating glb file
  63915. * @param options Exporter options
  63916. * @returns Returns an object with a .glb filename as key and data as value
  63917. */
  63918. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  63919. }
  63920. }
  63921. declare module BABYLON.GLTF2.Exporter {
  63922. /**
  63923. * @hidden
  63924. */
  63925. export class _GLTFUtilities {
  63926. /**
  63927. * Creates a buffer view based on the supplied arguments
  63928. * @param bufferIndex index value of the specified buffer
  63929. * @param byteOffset byte offset value
  63930. * @param byteLength byte length of the bufferView
  63931. * @param byteStride byte distance between conequential elements
  63932. * @param name name of the buffer view
  63933. * @returns bufferView for glTF
  63934. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  63935. /**
  63936. * Creates an accessor based on the supplied arguments
  63937. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  63938. * @param name The name of the accessor
  63939. * @param type The type of the accessor
  63940. * @param componentType The datatype of components in the attribute
  63941. * @param count The number of attributes referenced by this accessor
  63942. * @param byteOffset The offset relative to the start of the bufferView in bytes
  63943. * @param min Minimum value of each component in this attribute
  63944. * @param max Maximum value of each component in this attribute
  63945. * @returns accessor for glTF
  63946. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  63947. /**
  63948. * Calculates the minimum and maximum values of an array of position floats
  63949. * @param positions Positions array of a mesh
  63950. * @param vertexStart Starting vertex offset to calculate min and max values
  63951. * @param vertexCount Number of vertices to check for min and max values
  63952. * @returns min number array and max number array
  63953. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  63954. min: number[];
  63955. max: number[];
  63956. };
  63957. /**
  63958. * Converts a new right-handed Vector3
  63959. * @param vector vector3 array
  63960. * @returns right-handed Vector3
  63961. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  63962. /**
  63963. * Converts a Vector3 to right-handed
  63964. * @param vector Vector3 to convert to right-handed
  63965. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  63966. /**
  63967. * Converts a three element number array to right-handed
  63968. * @param vector number array to convert to right-handed
  63969. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  63970. /**
  63971. * Converts a new right-handed Vector3
  63972. * @param vector vector3 array
  63973. * @returns right-handed Vector3
  63974. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  63975. /**
  63976. * Converts a Vector3 to right-handed
  63977. * @param vector Vector3 to convert to right-handed
  63978. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  63979. /**
  63980. * Converts a three element number array to right-handed
  63981. * @param vector number array to convert to right-handed
  63982. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  63983. /**
  63984. * Converts a Vector4 to right-handed
  63985. * @param vector Vector4 to convert to right-handed
  63986. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  63987. /**
  63988. * Converts a Vector4 to right-handed
  63989. * @param vector Vector4 to convert to right-handed
  63990. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  63991. /**
  63992. * Converts a Quaternion to right-handed
  63993. * @param quaternion Source quaternion to convert to right-handed
  63994. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  63995. /**
  63996. * Converts a Quaternion to right-handed
  63997. * @param quaternion Source quaternion to convert to right-handed
  63998. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  63999. }
  64000. }
  64001. declare module BABYLON.GLTF2.Exporter {
  64002. /**
  64003. * Converts Babylon Scene into glTF 2.0.
  64004. * @hidden
  64005. */
  64006. export class _Exporter {
  64007. /**
  64008. * Stores the glTF to export
  64009. */ private _glTF: IGLTF;
  64010. /**
  64011. * Stores all generated buffer views, which represents views into the main glTF buffer data
  64012. */ private _bufferViews: IBufferView[];
  64013. /**
  64014. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  64015. */ private _accessors: IAccessor[];
  64016. /**
  64017. * Stores all the generated nodes, which contains transform and/or mesh information per node
  64018. */
  64019. private _nodes;
  64020. /**
  64021. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  64022. */
  64023. private _scenes;
  64024. /**
  64025. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  64026. */
  64027. private _meshes;
  64028. /**
  64029. * Stores all the generated material information, which represents the appearance of each primitive
  64030. */ private _materials: IMaterial[]; private _materialMap: {
  64031. [materialID: number]: number;
  64032. };
  64033. /**
  64034. * Stores all the generated texture information, which is referenced by glTF materials
  64035. */ private _textures: ITexture[];
  64036. /**
  64037. * Stores all the generated image information, which is referenced by glTF textures
  64038. */ private _images: IImage[];
  64039. /**
  64040. * Stores all the texture samplers
  64041. */ private _samplers: ISampler[];
  64042. /**
  64043. * Stores all the generated animation samplers, which is referenced by glTF animations
  64044. */
  64045. /**
  64046. * Stores the animations for glTF models
  64047. */
  64048. private _animations;
  64049. /**
  64050. * Stores the total amount of bytes stored in the glTF buffer
  64051. */
  64052. private _totalByteLength;
  64053. /**
  64054. * Stores a reference to the Babylon scene containing the source geometry and material information
  64055. */ private _babylonScene: Scene;
  64056. /**
  64057. * Stores a map of the image data, where the key is the file name and the value
  64058. * is the image data
  64059. */ private _imageData: {
  64060. [fileName: string]: {
  64061. data: Uint8Array;
  64062. mimeType: ImageMimeType;
  64063. };
  64064. };
  64065. /**
  64066. * Stores a map of the unique id of a node to its index in the node array
  64067. */
  64068. private _nodeMap;
  64069. /**
  64070. * Specifies if the Babylon scene should be converted to right-handed on export
  64071. */ private _convertToRightHandedSystem: boolean;
  64072. /**
  64073. * Baked animation sample rate
  64074. */
  64075. private _animationSampleRate;
  64076. /**
  64077. * Callback which specifies if a node should be exported or not
  64078. */
  64079. private _shouldExportNode;
  64080. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  64081. private _extensions;
  64082. private static _ExtensionNames;
  64083. private static _ExtensionFactories;
  64084. private _applyExtensions; private _extensionsPreExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<BaseTexture>>; private _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>; private _extensionsPostExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64085. private _forEachExtensions;
  64086. private _extensionsOnExporting;
  64087. /**
  64088. * Load glTF serializer extensions
  64089. */
  64090. private _loadExtensions;
  64091. /**
  64092. * Creates a glTF Exporter instance, which can accept optional exporter options
  64093. * @param babylonScene Babylon scene object
  64094. * @param options Options to modify the behavior of the exporter
  64095. */
  64096. constructor(babylonScene: Scene, options?: IExportOptions);
  64097. /**
  64098. * Registers a glTF exporter extension
  64099. * @param name Name of the extension to export
  64100. * @param factory The factory function that creates the exporter extension
  64101. */
  64102. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  64103. /**
  64104. * Un-registers an exporter extension
  64105. * @param name The name fo the exporter extension
  64106. * @returns A boolean indicating whether the extension has been un-registered
  64107. */
  64108. static UnregisterExtension(name: string): boolean;
  64109. /**
  64110. * Lazy load a local engine with premultiplied alpha set to false
  64111. */ private _getLocalEngine(): Engine;
  64112. private reorderIndicesBasedOnPrimitiveMode;
  64113. /**
  64114. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  64115. * clock-wise during export to glTF
  64116. * @param submesh BabylonJS submesh
  64117. * @param primitiveMode Primitive mode of the mesh
  64118. * @param sideOrientation the winding order of the submesh
  64119. * @param vertexBufferKind The type of vertex attribute
  64120. * @param meshAttributeArray The vertex attribute data
  64121. * @param byteOffset The offset to the binary data
  64122. * @param binaryWriter The binary data for the glTF file
  64123. */
  64124. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  64125. /**
  64126. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  64127. * clock-wise during export to glTF
  64128. * @param submesh BabylonJS submesh
  64129. * @param primitiveMode Primitive mode of the mesh
  64130. * @param sideOrientation the winding order of the submesh
  64131. * @param vertexBufferKind The type of vertex attribute
  64132. * @param meshAttributeArray The vertex attribute data
  64133. * @param byteOffset The offset to the binary data
  64134. * @param binaryWriter The binary data for the glTF file
  64135. */
  64136. private reorderTriangleFillMode;
  64137. /**
  64138. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  64139. * clock-wise during export to glTF
  64140. * @param submesh BabylonJS submesh
  64141. * @param primitiveMode Primitive mode of the mesh
  64142. * @param sideOrientation the winding order of the submesh
  64143. * @param vertexBufferKind The type of vertex attribute
  64144. * @param meshAttributeArray The vertex attribute data
  64145. * @param byteOffset The offset to the binary data
  64146. * @param binaryWriter The binary data for the glTF file
  64147. */
  64148. private reorderTriangleStripDrawMode;
  64149. /**
  64150. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  64151. * clock-wise during export to glTF
  64152. * @param submesh BabylonJS submesh
  64153. * @param primitiveMode Primitive mode of the mesh
  64154. * @param sideOrientation the winding order of the submesh
  64155. * @param vertexBufferKind The type of vertex attribute
  64156. * @param meshAttributeArray The vertex attribute data
  64157. * @param byteOffset The offset to the binary data
  64158. * @param binaryWriter The binary data for the glTF file
  64159. */
  64160. private reorderTriangleFanMode;
  64161. /**
  64162. * Writes the vertex attribute data to binary
  64163. * @param vertices The vertices to write to the binary writer
  64164. * @param byteOffset The offset into the binary writer to overwrite binary data
  64165. * @param vertexAttributeKind The vertex attribute type
  64166. * @param meshAttributeArray The vertex attribute data
  64167. * @param binaryWriter The writer containing the binary data
  64168. */
  64169. private writeVertexAttributeData;
  64170. /**
  64171. * Writes mesh attribute data to a data buffer
  64172. * Returns the bytelength of the data
  64173. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  64174. * @param meshAttributeArray Array containing the attribute data
  64175. * @param binaryWriter The buffer to write the binary data to
  64176. * @param indices Used to specify the order of the vertex data
  64177. */
  64178. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  64179. /**
  64180. * Generates glTF json data
  64181. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  64182. * @param glTFPrefix Text to use when prefixing a glTF file
  64183. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  64184. * @returns json data as string
  64185. */
  64186. private generateJSON;
  64187. /**
  64188. * Generates data for .gltf and .bin files based on the glTF prefix string
  64189. * @param glTFPrefix Text to use when prefixing a glTF file
  64190. * @returns GLTFData with glTF file data
  64191. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  64192. /**
  64193. * Creates a binary buffer for glTF
  64194. * @returns array buffer for binary data
  64195. */
  64196. private _generateBinaryAsync;
  64197. /**
  64198. * Pads the number to a multiple of 4
  64199. * @param num number to pad
  64200. * @returns padded number
  64201. */
  64202. private _getPadding;
  64203. /**
  64204. * Generates a glb file from the json and binary data
  64205. * Returns an object with the glb file name as the key and data as the value
  64206. * @param glTFPrefix
  64207. * @returns object with glb filename as key and data as value
  64208. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  64209. /**
  64210. * Sets the TRS for each node
  64211. * @param node glTF Node for storing the transformation data
  64212. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  64213. */
  64214. private setNodeTransformation;
  64215. private getVertexBufferFromMesh;
  64216. /**
  64217. * Creates a bufferview based on the vertices type for the Babylon mesh
  64218. * @param kind Indicates the type of vertices data
  64219. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  64220. * @param binaryWriter The buffer to write the bufferview data to
  64221. */
  64222. private createBufferViewKind;
  64223. /**
  64224. * The primitive mode of the Babylon mesh
  64225. * @param babylonMesh The BabylonJS mesh
  64226. */
  64227. private getMeshPrimitiveMode;
  64228. /**
  64229. * Sets the primitive mode of the glTF mesh primitive
  64230. * @param meshPrimitive glTF mesh primitive
  64231. * @param primitiveMode The primitive mode
  64232. */
  64233. private setPrimitiveMode;
  64234. /**
  64235. * Sets the vertex attribute accessor based of the glTF mesh primitive
  64236. * @param meshPrimitive glTF mesh primitive
  64237. * @param attributeKind vertex attribute
  64238. * @returns boolean specifying if uv coordinates are present
  64239. */
  64240. private setAttributeKind;
  64241. /**
  64242. * Sets data for the primitive attributes of each submesh
  64243. * @param mesh glTF Mesh object to store the primitive attribute information
  64244. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  64245. * @param binaryWriter Buffer to write the attribute data to
  64246. */
  64247. private setPrimitiveAttributesAsync;
  64248. /**
  64249. * Creates a glTF scene based on the array of meshes
  64250. * Returns the the total byte offset
  64251. * @param babylonScene Babylon scene to get the mesh data from
  64252. * @param binaryWriter Buffer to write binary data to
  64253. */
  64254. private createSceneAsync;
  64255. /**
  64256. * Creates a mapping of Node unique id to node index and handles animations
  64257. * @param babylonScene Babylon Scene
  64258. * @param nodes Babylon transform nodes
  64259. * @param shouldExportNode Callback specifying if a transform node should be exported
  64260. * @param binaryWriter Buffer to write binary data to
  64261. * @returns Node mapping of unique id to index
  64262. */
  64263. private createNodeMapAndAnimationsAsync;
  64264. /**
  64265. * Creates a glTF node from a Babylon mesh
  64266. * @param babylonMesh Source Babylon mesh
  64267. * @param binaryWriter Buffer for storing geometry data
  64268. * @returns glTF node
  64269. */
  64270. private createNodeAsync;
  64271. }
  64272. /**
  64273. * @hidden
  64274. *
  64275. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  64276. */
  64277. export class _BinaryWriter {
  64278. /**
  64279. * Array buffer which stores all binary data
  64280. */
  64281. private _arrayBuffer;
  64282. /**
  64283. * View of the array buffer
  64284. */
  64285. private _dataView;
  64286. /**
  64287. * byte offset of data in array buffer
  64288. */
  64289. private _byteOffset;
  64290. /**
  64291. * Initialize binary writer with an initial byte length
  64292. * @param byteLength Initial byte length of the array buffer
  64293. */
  64294. constructor(byteLength: number);
  64295. /**
  64296. * Resize the array buffer to the specified byte length
  64297. * @param byteLength
  64298. */
  64299. private resizeBuffer;
  64300. /**
  64301. * Get an array buffer with the length of the byte offset
  64302. * @returns ArrayBuffer resized to the byte offset
  64303. */
  64304. getArrayBuffer(): ArrayBuffer;
  64305. /**
  64306. * Get the byte offset of the array buffer
  64307. * @returns byte offset
  64308. */
  64309. getByteOffset(): number;
  64310. /**
  64311. * Stores an UInt8 in the array buffer
  64312. * @param entry
  64313. * @param byteOffset If defined, specifies where to set the value as an offset.
  64314. */
  64315. setUInt8(entry: number, byteOffset?: number): void;
  64316. /**
  64317. * Gets an UInt32 in the array buffer
  64318. * @param entry
  64319. * @param byteOffset If defined, specifies where to set the value as an offset.
  64320. */
  64321. getUInt32(byteOffset: number): number;
  64322. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  64323. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  64324. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  64325. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  64326. /**
  64327. * Stores a Float32 in the array buffer
  64328. * @param entry
  64329. */
  64330. setFloat32(entry: number, byteOffset?: number): void;
  64331. /**
  64332. * Stores an UInt32 in the array buffer
  64333. * @param entry
  64334. * @param byteOffset If defined, specifies where to set the value as an offset.
  64335. */
  64336. setUInt32(entry: number, byteOffset?: number): void;
  64337. }
  64338. }
  64339. declare module BABYLON.GLTF2.Exporter {
  64340. /**
  64341. * @hidden
  64342. * Interface to store animation data.
  64343. */
  64344. export interface _IAnimationData {
  64345. /**
  64346. * Keyframe data.
  64347. */
  64348. inputs: number[];
  64349. /**
  64350. * Value data.
  64351. */
  64352. outputs: number[][];
  64353. /**
  64354. * Animation interpolation data.
  64355. */
  64356. samplerInterpolation: AnimationSamplerInterpolation;
  64357. /**
  64358. * Minimum keyframe value.
  64359. */
  64360. inputsMin: number;
  64361. /**
  64362. * Maximum keyframe value.
  64363. */
  64364. inputsMax: number;
  64365. }
  64366. /**
  64367. * @hidden
  64368. */
  64369. export interface _IAnimationInfo {
  64370. /**
  64371. * The target channel for the animation
  64372. */
  64373. animationChannelTargetPath: AnimationChannelTargetPath;
  64374. /**
  64375. * The glTF accessor type for the data.
  64376. */
  64377. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  64378. /**
  64379. * Specifies if quaternions should be used.
  64380. */
  64381. useQuaternion: boolean;
  64382. }
  64383. /**
  64384. * @hidden
  64385. * Utility class for generating glTF animation data from BabylonJS.
  64386. */
  64387. export class _GLTFAnimation {
  64388. /**
  64389. * @ignore
  64390. *
  64391. * Creates glTF channel animation from BabylonJS animation.
  64392. * @param babylonTransformNode - BabylonJS mesh.
  64393. * @param animation - animation.
  64394. * @param animationChannelTargetPath - The target animation channel.
  64395. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  64396. * @param useQuaternion - Specifies if quaternions are used.
  64397. * @returns nullable IAnimationData
  64398. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  64399. private static _DeduceAnimationInfo;
  64400. /**
  64401. * @ignore
  64402. * Create node animations from the transform node animations
  64403. * @param babylonNode
  64404. * @param runtimeGLTFAnimation
  64405. * @param idleGLTFAnimations
  64406. * @param nodeMap
  64407. * @param nodes
  64408. * @param binaryWriter
  64409. * @param bufferViews
  64410. * @param accessors
  64411. * @param convertToRightHandedSystem
  64412. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  64413. [key: number]: number;
  64414. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  64415. /**
  64416. * @ignore
  64417. * Create node animations from the animation groups
  64418. * @param babylonScene
  64419. * @param glTFAnimations
  64420. * @param nodeMap
  64421. * @param nodes
  64422. * @param binaryWriter
  64423. * @param bufferViews
  64424. * @param accessors
  64425. * @param convertToRightHandedSystem
  64426. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  64427. [key: number]: number;
  64428. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  64429. private static AddAnimation;
  64430. /**
  64431. * Create a baked animation
  64432. * @param babylonTransformNode BabylonJS mesh
  64433. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  64434. * @param animationChannelTargetPath animation target channel
  64435. * @param minFrame minimum animation frame
  64436. * @param maxFrame maximum animation frame
  64437. * @param fps frames per second of the animation
  64438. * @param inputs input key frames of the animation
  64439. * @param outputs output key frame data of the animation
  64440. * @param convertToRightHandedSystem converts the values to right-handed
  64441. * @param useQuaternion specifies if quaternions should be used
  64442. */
  64443. private static _CreateBakedAnimation;
  64444. private static _ConvertFactorToVector3OrQuaternion;
  64445. private static _SetInterpolatedValue;
  64446. /**
  64447. * Creates linear animation from the animation key frames
  64448. * @param babylonTransformNode BabylonJS mesh
  64449. * @param animation BabylonJS animation
  64450. * @param animationChannelTargetPath The target animation channel
  64451. * @param frameDelta The difference between the last and first frame of the animation
  64452. * @param inputs Array to store the key frame times
  64453. * @param outputs Array to store the key frame data
  64454. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  64455. * @param useQuaternion Specifies if quaternions are used in the animation
  64456. */
  64457. private static _CreateLinearOrStepAnimation;
  64458. /**
  64459. * Creates cubic spline animation from the animation key frames
  64460. * @param babylonTransformNode BabylonJS mesh
  64461. * @param animation BabylonJS animation
  64462. * @param animationChannelTargetPath The target animation channel
  64463. * @param frameDelta The difference between the last and first frame of the animation
  64464. * @param inputs Array to store the key frame times
  64465. * @param outputs Array to store the key frame data
  64466. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  64467. * @param useQuaternion Specifies if quaternions are used in the animation
  64468. */
  64469. private static _CreateCubicSplineAnimation;
  64470. private static _GetBasePositionRotationOrScale;
  64471. /**
  64472. * Adds a key frame value
  64473. * @param keyFrame
  64474. * @param animation
  64475. * @param outputs
  64476. * @param animationChannelTargetPath
  64477. * @param basePositionRotationOrScale
  64478. * @param convertToRightHandedSystem
  64479. * @param useQuaternion
  64480. */
  64481. private static _AddKeyframeValue;
  64482. /**
  64483. * Determine the interpolation based on the key frames
  64484. * @param keyFrames
  64485. * @param animationChannelTargetPath
  64486. * @param useQuaternion
  64487. */
  64488. private static _DeduceInterpolation;
  64489. /**
  64490. * Adds an input tangent or output tangent to the output data
  64491. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  64492. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  64493. * @param outputs The animation data by keyframe
  64494. * @param animationChannelTargetPath The target animation channel
  64495. * @param interpolation The interpolation type
  64496. * @param keyFrame The key frame with the animation data
  64497. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  64498. * @param useQuaternion Specifies if quaternions are used
  64499. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  64500. */
  64501. private static AddSplineTangent;
  64502. /**
  64503. * Get the minimum and maximum key frames' frame values
  64504. * @param keyFrames animation key frames
  64505. * @returns the minimum and maximum key frame value
  64506. */
  64507. private static calculateMinMaxKeyFrames;
  64508. }
  64509. }
  64510. declare module BABYLON.GLTF2.Exporter {
  64511. /** @hidden */
  64512. export var textureTransformPixelShader: {
  64513. name: string;
  64514. shader: string;
  64515. };
  64516. }
  64517. declare module BABYLON.GLTF2.Exporter.Extensions {
  64518. /**
  64519. * @hidden
  64520. */
  64521. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  64522. /** Name of this extension */
  64523. readonly name: string;
  64524. /** Defines whether this extension is enabled */
  64525. enabled: boolean;
  64526. /** Defines whether this extension is required */
  64527. required: boolean;
  64528. /** Reference to the glTF exporter */
  64529. private _exporter;
  64530. constructor(exporter: _Exporter);
  64531. dispose(): void;
  64532. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  64533. /**
  64534. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  64535. * @param babylonTexture
  64536. * @param offset
  64537. * @param rotation
  64538. * @param scale
  64539. * @param scene
  64540. */
  64541. textureTransformTextureAsync(babylonTexture: Texture, offset: Vector2, rotation: number, scale: Vector2, scene: Scene): Promise<BaseTexture>;
  64542. }
  64543. }
  64544. declare module BABYLON.GLTF2.Exporter.Extensions {
  64545. /**
  64546. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  64547. */
  64548. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  64549. /** The name of this extension. */
  64550. readonly name: string;
  64551. /** Defines whether this extension is enabled. */
  64552. enabled: boolean;
  64553. /** Defines whether this extension is required */
  64554. required: boolean;
  64555. /** Reference to the glTF exporter */
  64556. private _exporter;
  64557. private _lights;
  64558. /** @hidden */
  64559. constructor(exporter: _Exporter);
  64560. /** @hidden */
  64561. dispose(): void;
  64562. /** @hidden */
  64563. onExporting(): void;
  64564. /**
  64565. * Define this method to modify the default behavior when exporting a node
  64566. * @param context The context when exporting the node
  64567. * @param node glTF node
  64568. * @param babylonNode BabylonJS node
  64569. * @returns nullable INode promise
  64570. */
  64571. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  64572. }
  64573. }
  64574. declare module BABYLON {
  64575. /**
  64576. * Class for generating STL data from a Babylon scene.
  64577. */
  64578. export class STLExport {
  64579. /**
  64580. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  64581. * @param meshes list defines the mesh to serialize
  64582. * @param download triggers the automatic download of the file.
  64583. * @param fileName changes the downloads fileName.
  64584. * @param binary changes the STL to a binary type.
  64585. * @param isLittleEndian toggle for binary type exporter.
  64586. * @returns the STL as UTF8 string
  64587. */
  64588. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  64589. }
  64590. }
  64591. /**
  64592. * @ignoreChildren
  64593. * @ignore
  64594. */
  64595. declare module "babylonjs-gltf2interface" {
  64596. export = BABYLON.GLTF2;
  64597. }
  64598. /**
  64599. * Module for glTF 2.0 Interface
  64600. * @ignoreChildren
  64601. * @ignore
  64602. */
  64603. declare module BABYLON.GLTF2 {
  64604. /**
  64605. * The datatype of the components in the attribute
  64606. */
  64607. const enum AccessorComponentType {
  64608. /**
  64609. * Byte
  64610. */
  64611. BYTE = 5120,
  64612. /**
  64613. * Unsigned Byte
  64614. */
  64615. UNSIGNED_BYTE = 5121,
  64616. /**
  64617. * Short
  64618. */
  64619. SHORT = 5122,
  64620. /**
  64621. * Unsigned Short
  64622. */
  64623. UNSIGNED_SHORT = 5123,
  64624. /**
  64625. * Unsigned Int
  64626. */
  64627. UNSIGNED_INT = 5125,
  64628. /**
  64629. * Float
  64630. */
  64631. FLOAT = 5126,
  64632. }
  64633. /**
  64634. * Specifies if the attirbute is a scalar, vector, or matrix
  64635. */
  64636. const enum AccessorType {
  64637. /**
  64638. * Scalar
  64639. */
  64640. SCALAR = "SCALAR",
  64641. /**
  64642. * Vector2
  64643. */
  64644. VEC2 = "VEC2",
  64645. /**
  64646. * Vector3
  64647. */
  64648. VEC3 = "VEC3",
  64649. /**
  64650. * Vector4
  64651. */
  64652. VEC4 = "VEC4",
  64653. /**
  64654. * Matrix2x2
  64655. */
  64656. MAT2 = "MAT2",
  64657. /**
  64658. * Matrix3x3
  64659. */
  64660. MAT3 = "MAT3",
  64661. /**
  64662. * Matrix4x4
  64663. */
  64664. MAT4 = "MAT4",
  64665. }
  64666. /**
  64667. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  64668. */
  64669. const enum AnimationChannelTargetPath {
  64670. /**
  64671. * Translation
  64672. */
  64673. TRANSLATION = "translation",
  64674. /**
  64675. * Rotation
  64676. */
  64677. ROTATION = "rotation",
  64678. /**
  64679. * Scale
  64680. */
  64681. SCALE = "scale",
  64682. /**
  64683. * Weights
  64684. */
  64685. WEIGHTS = "weights",
  64686. }
  64687. /**
  64688. * Interpolation algorithm
  64689. */
  64690. const enum AnimationSamplerInterpolation {
  64691. /**
  64692. * The animated values are linearly interpolated between keyframes
  64693. */
  64694. LINEAR = "LINEAR",
  64695. /**
  64696. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  64697. */
  64698. STEP = "STEP",
  64699. /**
  64700. * The animation's interpolation is computed using a cubic spline with specified tangents
  64701. */
  64702. CUBICSPLINE = "CUBICSPLINE",
  64703. }
  64704. /**
  64705. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  64706. */
  64707. const enum CameraType {
  64708. /**
  64709. * A perspective camera containing properties to create a perspective projection matrix
  64710. */
  64711. PERSPECTIVE = "perspective",
  64712. /**
  64713. * An orthographic camera containing properties to create an orthographic projection matrix
  64714. */
  64715. ORTHOGRAPHIC = "orthographic",
  64716. }
  64717. /**
  64718. * The mime-type of the image
  64719. */
  64720. const enum ImageMimeType {
  64721. /**
  64722. * JPEG Mime-type
  64723. */
  64724. JPEG = "image/jpeg",
  64725. /**
  64726. * PNG Mime-type
  64727. */
  64728. PNG = "image/png",
  64729. }
  64730. /**
  64731. * The alpha rendering mode of the material
  64732. */
  64733. const enum MaterialAlphaMode {
  64734. /**
  64735. * The alpha value is ignored and the rendered output is fully opaque
  64736. */
  64737. OPAQUE = "OPAQUE",
  64738. /**
  64739. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  64740. */
  64741. MASK = "MASK",
  64742. /**
  64743. * 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)
  64744. */
  64745. BLEND = "BLEND",
  64746. }
  64747. /**
  64748. * The type of the primitives to render
  64749. */
  64750. const enum MeshPrimitiveMode {
  64751. /**
  64752. * Points
  64753. */
  64754. POINTS = 0,
  64755. /**
  64756. * Lines
  64757. */
  64758. LINES = 1,
  64759. /**
  64760. * Line Loop
  64761. */
  64762. LINE_LOOP = 2,
  64763. /**
  64764. * Line Strip
  64765. */
  64766. LINE_STRIP = 3,
  64767. /**
  64768. * Triangles
  64769. */
  64770. TRIANGLES = 4,
  64771. /**
  64772. * Triangle Strip
  64773. */
  64774. TRIANGLE_STRIP = 5,
  64775. /**
  64776. * Triangle Fan
  64777. */
  64778. TRIANGLE_FAN = 6,
  64779. }
  64780. /**
  64781. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  64782. */
  64783. const enum TextureMagFilter {
  64784. /**
  64785. * Nearest
  64786. */
  64787. NEAREST = 9728,
  64788. /**
  64789. * Linear
  64790. */
  64791. LINEAR = 9729,
  64792. }
  64793. /**
  64794. * Minification filter. All valid values correspond to WebGL enums
  64795. */
  64796. const enum TextureMinFilter {
  64797. /**
  64798. * Nearest
  64799. */
  64800. NEAREST = 9728,
  64801. /**
  64802. * Linear
  64803. */
  64804. LINEAR = 9729,
  64805. /**
  64806. * Nearest Mip-Map Nearest
  64807. */
  64808. NEAREST_MIPMAP_NEAREST = 9984,
  64809. /**
  64810. * Linear Mipmap Nearest
  64811. */
  64812. LINEAR_MIPMAP_NEAREST = 9985,
  64813. /**
  64814. * Nearest Mipmap Linear
  64815. */
  64816. NEAREST_MIPMAP_LINEAR = 9986,
  64817. /**
  64818. * Linear Mipmap Linear
  64819. */
  64820. LINEAR_MIPMAP_LINEAR = 9987,
  64821. }
  64822. /**
  64823. * S (U) wrapping mode. All valid values correspond to WebGL enums
  64824. */
  64825. const enum TextureWrapMode {
  64826. /**
  64827. * Clamp to Edge
  64828. */
  64829. CLAMP_TO_EDGE = 33071,
  64830. /**
  64831. * Mirrored Repeat
  64832. */
  64833. MIRRORED_REPEAT = 33648,
  64834. /**
  64835. * Repeat
  64836. */
  64837. REPEAT = 10497,
  64838. }
  64839. /**
  64840. * glTF Property
  64841. */
  64842. interface IProperty {
  64843. /**
  64844. * Dictionary object with extension-specific objects
  64845. */
  64846. extensions?: {
  64847. [key: string]: any;
  64848. };
  64849. /**
  64850. * Application-Specific data
  64851. */
  64852. extras?: any;
  64853. }
  64854. /**
  64855. * glTF Child of Root Property
  64856. */
  64857. interface IChildRootProperty extends IProperty {
  64858. /**
  64859. * The user-defined name of this object
  64860. */
  64861. name?: string;
  64862. }
  64863. /**
  64864. * Indices of those attributes that deviate from their initialization value
  64865. */
  64866. interface IAccessorSparseIndices extends IProperty {
  64867. /**
  64868. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  64869. */
  64870. bufferView: number;
  64871. /**
  64872. * The offset relative to the start of the bufferView in bytes. Must be aligned
  64873. */
  64874. byteOffset?: number;
  64875. /**
  64876. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  64877. */
  64878. componentType: AccessorComponentType;
  64879. }
  64880. /**
  64881. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  64882. */
  64883. interface IAccessorSparseValues extends IProperty {
  64884. /**
  64885. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  64886. */
  64887. bufferView: number;
  64888. /**
  64889. * The offset relative to the start of the bufferView in bytes. Must be aligned
  64890. */
  64891. byteOffset?: number;
  64892. }
  64893. /**
  64894. * Sparse storage of attributes that deviate from their initialization value
  64895. */
  64896. interface IAccessorSparse extends IProperty {
  64897. /**
  64898. * The number of attributes encoded in this sparse accessor
  64899. */
  64900. count: number;
  64901. /**
  64902. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  64903. */
  64904. indices: IAccessorSparseIndices;
  64905. /**
  64906. * 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
  64907. */
  64908. values: IAccessorSparseValues;
  64909. }
  64910. /**
  64911. * 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
  64912. */
  64913. interface IAccessor extends IChildRootProperty {
  64914. /**
  64915. * The index of the bufferview
  64916. */
  64917. bufferView?: number;
  64918. /**
  64919. * The offset relative to the start of the bufferView in bytes
  64920. */
  64921. byteOffset?: number;
  64922. /**
  64923. * The datatype of components in the attribute
  64924. */
  64925. componentType: AccessorComponentType;
  64926. /**
  64927. * Specifies whether integer data values should be normalized
  64928. */
  64929. normalized?: boolean;
  64930. /**
  64931. * The number of attributes referenced by this accessor
  64932. */
  64933. count: number;
  64934. /**
  64935. * Specifies if the attribute is a scalar, vector, or matrix
  64936. */
  64937. type: AccessorType;
  64938. /**
  64939. * Maximum value of each component in this attribute
  64940. */
  64941. max?: number[];
  64942. /**
  64943. * Minimum value of each component in this attribute
  64944. */
  64945. min?: number[];
  64946. /**
  64947. * Sparse storage of attributes that deviate from their initialization value
  64948. */
  64949. sparse?: IAccessorSparse;
  64950. }
  64951. /**
  64952. * Targets an animation's sampler at a node's property
  64953. */
  64954. interface IAnimationChannel extends IProperty {
  64955. /**
  64956. * The index of a sampler in this animation used to compute the value for the target
  64957. */
  64958. sampler: number;
  64959. /**
  64960. * The index of the node and TRS property to target
  64961. */
  64962. target: IAnimationChannelTarget;
  64963. }
  64964. /**
  64965. * The index of the node and TRS property that an animation channel targets
  64966. */
  64967. interface IAnimationChannelTarget extends IProperty {
  64968. /**
  64969. * The index of the node to target
  64970. */
  64971. node: number;
  64972. /**
  64973. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  64974. */
  64975. path: AnimationChannelTargetPath;
  64976. }
  64977. /**
  64978. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  64979. */
  64980. interface IAnimationSampler extends IProperty {
  64981. /**
  64982. * The index of an accessor containing keyframe input values, e.g., time
  64983. */
  64984. input: number;
  64985. /**
  64986. * Interpolation algorithm
  64987. */
  64988. interpolation?: AnimationSamplerInterpolation;
  64989. /**
  64990. * The index of an accessor, containing keyframe output values
  64991. */
  64992. output: number;
  64993. }
  64994. /**
  64995. * A keyframe animation
  64996. */
  64997. interface IAnimation extends IChildRootProperty {
  64998. /**
  64999. * An array of channels, each of which targets an animation's sampler at a node's property
  65000. */
  65001. channels: IAnimationChannel[];
  65002. /**
  65003. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  65004. */
  65005. samplers: IAnimationSampler[];
  65006. }
  65007. /**
  65008. * Metadata about the glTF asset
  65009. */
  65010. interface IAsset extends IChildRootProperty {
  65011. /**
  65012. * A copyright message suitable for display to credit the content creator
  65013. */
  65014. copyright?: string;
  65015. /**
  65016. * Tool that generated this glTF model. Useful for debugging
  65017. */
  65018. generator?: string;
  65019. /**
  65020. * The glTF version that this asset targets
  65021. */
  65022. version: string;
  65023. /**
  65024. * The minimum glTF version that this asset targets
  65025. */
  65026. minVersion?: string;
  65027. }
  65028. /**
  65029. * A buffer points to binary geometry, animation, or skins
  65030. */
  65031. interface IBuffer extends IChildRootProperty {
  65032. /**
  65033. * 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
  65034. */
  65035. uri?: string;
  65036. /**
  65037. * The length of the buffer in bytes
  65038. */
  65039. byteLength: number;
  65040. }
  65041. /**
  65042. * A view into a buffer generally representing a subset of the buffer
  65043. */
  65044. interface IBufferView extends IChildRootProperty {
  65045. /**
  65046. * The index of the buffer
  65047. */
  65048. buffer: number;
  65049. /**
  65050. * The offset into the buffer in bytes
  65051. */
  65052. byteOffset?: number;
  65053. /**
  65054. * The lenth of the bufferView in bytes
  65055. */
  65056. byteLength: number;
  65057. /**
  65058. * The stride, in bytes
  65059. */
  65060. byteStride?: number;
  65061. }
  65062. /**
  65063. * An orthographic camera containing properties to create an orthographic projection matrix
  65064. */
  65065. interface ICameraOrthographic extends IProperty {
  65066. /**
  65067. * The floating-point horizontal magnification of the view. Must not be zero
  65068. */
  65069. xmag: number;
  65070. /**
  65071. * The floating-point vertical magnification of the view. Must not be zero
  65072. */
  65073. ymag: number;
  65074. /**
  65075. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  65076. */
  65077. zfar: number;
  65078. /**
  65079. * The floating-point distance to the near clipping plane
  65080. */
  65081. znear: number;
  65082. }
  65083. /**
  65084. * A perspective camera containing properties to create a perspective projection matrix
  65085. */
  65086. interface ICameraPerspective extends IProperty {
  65087. /**
  65088. * The floating-point aspect ratio of the field of view
  65089. */
  65090. aspectRatio?: number;
  65091. /**
  65092. * The floating-point vertical field of view in radians
  65093. */
  65094. yfov: number;
  65095. /**
  65096. * The floating-point distance to the far clipping plane
  65097. */
  65098. zfar?: number;
  65099. /**
  65100. * The floating-point distance to the near clipping plane
  65101. */
  65102. znear: number;
  65103. }
  65104. /**
  65105. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  65106. */
  65107. interface ICamera extends IChildRootProperty {
  65108. /**
  65109. * An orthographic camera containing properties to create an orthographic projection matrix
  65110. */
  65111. orthographic?: ICameraOrthographic;
  65112. /**
  65113. * A perspective camera containing properties to create a perspective projection matrix
  65114. */
  65115. perspective?: ICameraPerspective;
  65116. /**
  65117. * Specifies if the camera uses a perspective or orthographic projection
  65118. */
  65119. type: CameraType;
  65120. }
  65121. /**
  65122. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  65123. */
  65124. interface IImage extends IChildRootProperty {
  65125. /**
  65126. * 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
  65127. */
  65128. uri?: string;
  65129. /**
  65130. * The image's MIME type
  65131. */
  65132. mimeType?: ImageMimeType;
  65133. /**
  65134. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  65135. */
  65136. bufferView?: number;
  65137. }
  65138. /**
  65139. * Material Normal Texture Info
  65140. */
  65141. interface IMaterialNormalTextureInfo extends ITextureInfo {
  65142. /**
  65143. * The scalar multiplier applied to each normal vector of the normal texture
  65144. */
  65145. scale?: number;
  65146. }
  65147. /**
  65148. * Material Occlusion Texture Info
  65149. */
  65150. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  65151. /**
  65152. * A scalar multiplier controlling the amount of occlusion applied
  65153. */
  65154. strength?: number;
  65155. }
  65156. /**
  65157. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  65158. */
  65159. interface IMaterialPbrMetallicRoughness {
  65160. /**
  65161. * The material's base color factor
  65162. */
  65163. baseColorFactor?: number[];
  65164. /**
  65165. * The base color texture
  65166. */
  65167. baseColorTexture?: ITextureInfo;
  65168. /**
  65169. * The metalness of the material
  65170. */
  65171. metallicFactor?: number;
  65172. /**
  65173. * The roughness of the material
  65174. */
  65175. roughnessFactor?: number;
  65176. /**
  65177. * The metallic-roughness texture
  65178. */
  65179. metallicRoughnessTexture?: ITextureInfo;
  65180. }
  65181. /**
  65182. * The material appearance of a primitive
  65183. */
  65184. interface IMaterial extends IChildRootProperty {
  65185. /**
  65186. * 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
  65187. */
  65188. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65189. /**
  65190. * The normal map texture
  65191. */
  65192. normalTexture?: IMaterialNormalTextureInfo;
  65193. /**
  65194. * The occlusion map texture
  65195. */
  65196. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65197. /**
  65198. * The emissive map texture
  65199. */
  65200. emissiveTexture?: ITextureInfo;
  65201. /**
  65202. * 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
  65203. */
  65204. emissiveFactor?: number[];
  65205. /**
  65206. * The alpha rendering mode of the material
  65207. */
  65208. alphaMode?: MaterialAlphaMode;
  65209. /**
  65210. * The alpha cutoff value of the material
  65211. */
  65212. alphaCutoff?: number;
  65213. /**
  65214. * Specifies whether the material is double sided
  65215. */
  65216. doubleSided?: boolean;
  65217. }
  65218. /**
  65219. * Geometry to be rendered with the given material
  65220. */
  65221. interface IMeshPrimitive extends IProperty {
  65222. /**
  65223. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  65224. */
  65225. attributes: {
  65226. [name: string]: number;
  65227. };
  65228. /**
  65229. * The index of the accessor that contains the indices
  65230. */
  65231. indices?: number;
  65232. /**
  65233. * The index of the material to apply to this primitive when rendering
  65234. */
  65235. material?: number;
  65236. /**
  65237. * The type of primitives to render. All valid values correspond to WebGL enums
  65238. */
  65239. mode?: MeshPrimitiveMode;
  65240. /**
  65241. * 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
  65242. */
  65243. targets?: {
  65244. [name: string]: number;
  65245. }[];
  65246. }
  65247. /**
  65248. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  65249. */
  65250. interface IMesh extends IChildRootProperty {
  65251. /**
  65252. * An array of primitives, each defining geometry to be rendered with a material
  65253. */
  65254. primitives: IMeshPrimitive[];
  65255. /**
  65256. * Array of weights to be applied to the Morph Targets
  65257. */
  65258. weights?: number[];
  65259. }
  65260. /**
  65261. * A node in the node hierarchy
  65262. */
  65263. interface INode extends IChildRootProperty {
  65264. /**
  65265. * The index of the camera referenced by this node
  65266. */
  65267. camera?: number;
  65268. /**
  65269. * The indices of this node's children
  65270. */
  65271. children?: number[];
  65272. /**
  65273. * The index of the skin referenced by this node
  65274. */
  65275. skin?: number;
  65276. /**
  65277. * A floating-point 4x4 transformation matrix stored in column-major order
  65278. */
  65279. matrix?: number[];
  65280. /**
  65281. * The index of the mesh in this node
  65282. */
  65283. mesh?: number;
  65284. /**
  65285. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  65286. */
  65287. rotation?: number[];
  65288. /**
  65289. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  65290. */
  65291. scale?: number[];
  65292. /**
  65293. * The node's translation along the x, y, and z axes
  65294. */
  65295. translation?: number[];
  65296. /**
  65297. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  65298. */
  65299. weights?: number[];
  65300. }
  65301. /**
  65302. * Texture sampler properties for filtering and wrapping modes
  65303. */
  65304. interface ISampler extends IChildRootProperty {
  65305. /**
  65306. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  65307. */
  65308. magFilter?: TextureMagFilter;
  65309. /**
  65310. * Minification filter. All valid values correspond to WebGL enums
  65311. */
  65312. minFilter?: TextureMinFilter;
  65313. /**
  65314. * S (U) wrapping mode. All valid values correspond to WebGL enums
  65315. */
  65316. wrapS?: TextureWrapMode;
  65317. /**
  65318. * T (V) wrapping mode. All valid values correspond to WebGL enums
  65319. */
  65320. wrapT?: TextureWrapMode;
  65321. }
  65322. /**
  65323. * The root nodes of a scene
  65324. */
  65325. interface IScene extends IChildRootProperty {
  65326. /**
  65327. * The indices of each root node
  65328. */
  65329. nodes: number[];
  65330. }
  65331. /**
  65332. * Joints and matrices defining a skin
  65333. */
  65334. interface ISkin extends IChildRootProperty {
  65335. /**
  65336. * 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
  65337. */
  65338. inverseBindMatrices?: number;
  65339. /**
  65340. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  65341. */
  65342. skeleton?: number;
  65343. /**
  65344. * 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)
  65345. */
  65346. joints: number[];
  65347. }
  65348. /**
  65349. * A texture and its sampler
  65350. */
  65351. interface ITexture extends IChildRootProperty {
  65352. /**
  65353. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  65354. */
  65355. sampler?: number;
  65356. /**
  65357. * The index of the image used by this texture
  65358. */
  65359. source: number;
  65360. }
  65361. /**
  65362. * Reference to a texture
  65363. */
  65364. interface ITextureInfo extends IProperty {
  65365. /**
  65366. * The index of the texture
  65367. */
  65368. index: number;
  65369. /**
  65370. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  65371. */
  65372. texCoord?: number;
  65373. }
  65374. /**
  65375. * The root object for a glTF asset
  65376. */
  65377. interface IGLTF extends IProperty {
  65378. /**
  65379. * An array of accessors. An accessor is a typed view into a bufferView
  65380. */
  65381. accessors?: IAccessor[];
  65382. /**
  65383. * An array of keyframe animations
  65384. */
  65385. animations?: IAnimation[];
  65386. /**
  65387. * Metadata about the glTF asset
  65388. */
  65389. asset: IAsset;
  65390. /**
  65391. * An array of buffers. A buffer points to binary geometry, animation, or skins
  65392. */
  65393. buffers?: IBuffer[];
  65394. /**
  65395. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  65396. */
  65397. bufferViews?: IBufferView[];
  65398. /**
  65399. * An array of cameras
  65400. */
  65401. cameras?: ICamera[];
  65402. /**
  65403. * Names of glTF extensions used somewhere in this asset
  65404. */
  65405. extensionsUsed?: string[];
  65406. /**
  65407. * Names of glTF extensions required to properly load this asset
  65408. */
  65409. extensionsRequired?: string[];
  65410. /**
  65411. * An array of images. An image defines data used to create a texture
  65412. */
  65413. images?: IImage[];
  65414. /**
  65415. * An array of materials. A material defines the appearance of a primitive
  65416. */
  65417. materials?: IMaterial[];
  65418. /**
  65419. * An array of meshes. A mesh is a set of primitives to be rendered
  65420. */
  65421. meshes?: IMesh[];
  65422. /**
  65423. * An array of nodes
  65424. */
  65425. nodes?: INode[];
  65426. /**
  65427. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  65428. */
  65429. samplers?: ISampler[];
  65430. /**
  65431. * The index of the default scene
  65432. */
  65433. scene?: number;
  65434. /**
  65435. * An array of scenes
  65436. */
  65437. scenes?: IScene[];
  65438. /**
  65439. * An array of skins. A skin is defined by joints and matrices
  65440. */
  65441. skins?: ISkin[];
  65442. /**
  65443. * An array of textures
  65444. */
  65445. textures?: ITexture[];
  65446. }
  65447. /**
  65448. * The glTF validation results
  65449. */
  65450. interface IGLTFValidationResults {
  65451. info: {
  65452. generator: string;
  65453. hasAnimations: boolean;
  65454. hasDefaultScene: boolean;
  65455. hasMaterials: boolean;
  65456. hasMorphTargets: boolean;
  65457. hasSkins: boolean;
  65458. hasTextures: boolean;
  65459. maxAttributesUsed: number;
  65460. primitivesCount: number
  65461. };
  65462. issues: {
  65463. messages: Array<string>;
  65464. numErrors: number;
  65465. numHints: number;
  65466. numInfos: number;
  65467. numWarnings: number;
  65468. truncated: boolean
  65469. };
  65470. mimeType: string;
  65471. uri: string;
  65472. validatedAt: string;
  65473. validatorVersion: string;
  65474. }
  65475. /**
  65476. * The glTF validation options
  65477. */
  65478. interface IGLTFValidationOptions {
  65479. uri?: string;
  65480. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  65481. validateAccessorData?: boolean;
  65482. maxIssues?: number;
  65483. ignoredIssues?: Array<string>;
  65484. severityOverrides?: Object;
  65485. }
  65486. /**
  65487. * The glTF validator object
  65488. */
  65489. interface IGLTFValidator {
  65490. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  65491. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  65492. }
  65493. }
  65494. declare module BABYLON {
  65495. /** @hidden */
  65496. export var cellPixelShader: {
  65497. name: string;
  65498. shader: string;
  65499. };
  65500. }
  65501. declare module BABYLON {
  65502. /** @hidden */
  65503. export var cellVertexShader: {
  65504. name: string;
  65505. shader: string;
  65506. };
  65507. }
  65508. declare module BABYLON {
  65509. export class CellMaterial extends BABYLON.PushMaterial {
  65510. private _diffuseTexture;
  65511. diffuseTexture: BABYLON.BaseTexture;
  65512. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  65513. computeHighLevel: boolean;
  65514. private _disableLighting;
  65515. disableLighting: boolean;
  65516. private _maxSimultaneousLights;
  65517. maxSimultaneousLights: number;
  65518. private _renderId;
  65519. constructor(name: string, scene: BABYLON.Scene);
  65520. needAlphaBlending(): boolean;
  65521. needAlphaTesting(): boolean;
  65522. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65523. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65524. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65525. getAnimatables(): BABYLON.IAnimatable[];
  65526. getActiveTextures(): BABYLON.BaseTexture[];
  65527. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65528. dispose(forceDisposeEffect?: boolean): void;
  65529. getClassName(): string;
  65530. clone(name: string): CellMaterial;
  65531. serialize(): any;
  65532. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  65533. }
  65534. }
  65535. declare module BABYLON {
  65536. export class CustomShaderStructure {
  65537. FragmentStore: string;
  65538. VertexStore: string;
  65539. constructor();
  65540. }
  65541. export class ShaderSpecialParts {
  65542. constructor();
  65543. Fragment_Begin: string;
  65544. Fragment_Definitions: string;
  65545. Fragment_MainBegin: string;
  65546. Fragment_Custom_Diffuse: string;
  65547. Fragment_Before_Lights: string;
  65548. Fragment_Before_Fog: string;
  65549. Fragment_Custom_Alpha: string;
  65550. Fragment_Before_FragColor: string;
  65551. Vertex_Begin: string;
  65552. Vertex_Definitions: string;
  65553. Vertex_MainBegin: string;
  65554. Vertex_Before_PositionUpdated: string;
  65555. Vertex_Before_NormalUpdated: string;
  65556. Vertex_MainEnd: string;
  65557. }
  65558. export class CustomMaterial extends BABYLON.StandardMaterial {
  65559. static ShaderIndexer: number;
  65560. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  65561. FragmentShader: string;
  65562. VertexShader: string;
  65563. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  65564. ReviewUniform(name: string, arr: string[]): string[];
  65565. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  65566. constructor(name: string, scene: BABYLON.Scene);
  65567. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  65568. Fragment_Begin(shaderPart: string): CustomMaterial;
  65569. Fragment_Definitions(shaderPart: string): CustomMaterial;
  65570. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  65571. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  65572. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  65573. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  65574. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  65575. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  65576. Vertex_Begin(shaderPart: string): CustomMaterial;
  65577. Vertex_Definitions(shaderPart: string): CustomMaterial;
  65578. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  65579. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  65580. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  65581. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  65582. }
  65583. }
  65584. declare module BABYLON {
  65585. export class ShaderAlebdoParts {
  65586. constructor();
  65587. Fragment_Begin: string;
  65588. Fragment_Definitions: string;
  65589. Fragment_MainBegin: string;
  65590. Fragment_Custom_Albedo: string;
  65591. Fragment_Before_Lights: string;
  65592. Fragment_Custom_MetallicRoughness: string;
  65593. Fragment_Custom_MicroSurface: string;
  65594. Fragment_Before_Fog: string;
  65595. Fragment_Custom_Alpha: string;
  65596. Fragment_Before_FragColor: string;
  65597. Vertex_Begin: string;
  65598. Vertex_Definitions: string;
  65599. Vertex_MainBegin: string;
  65600. Vertex_Before_PositionUpdated: string;
  65601. Vertex_Before_NormalUpdated: string;
  65602. Vertex_MainEnd: string;
  65603. }
  65604. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  65605. static ShaderIndexer: number;
  65606. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  65607. FragmentShader: string;
  65608. VertexShader: string;
  65609. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  65610. ReviewUniform(name: string, arr: string[]): string[];
  65611. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  65612. constructor(name: string, scene: BABYLON.Scene);
  65613. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  65614. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  65615. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  65616. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  65617. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  65618. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  65619. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  65620. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  65621. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  65622. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  65623. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  65624. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  65625. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  65626. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  65627. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  65628. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  65629. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  65630. }
  65631. }
  65632. declare module BABYLON {
  65633. /** @hidden */
  65634. export var firePixelShader: {
  65635. name: string;
  65636. shader: string;
  65637. };
  65638. }
  65639. declare module BABYLON {
  65640. /** @hidden */
  65641. export var fireVertexShader: {
  65642. name: string;
  65643. shader: string;
  65644. };
  65645. }
  65646. declare module BABYLON {
  65647. export class FireMaterial extends BABYLON.PushMaterial {
  65648. private _diffuseTexture;
  65649. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65650. private _distortionTexture;
  65651. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65652. private _opacityTexture;
  65653. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  65654. diffuseColor: BABYLON.Color3;
  65655. speed: number;
  65656. private _scaledDiffuse;
  65657. private _renderId;
  65658. private _lastTime;
  65659. constructor(name: string, scene: BABYLON.Scene);
  65660. needAlphaBlending(): boolean;
  65661. needAlphaTesting(): boolean;
  65662. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65663. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65664. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65665. getAnimatables(): BABYLON.IAnimatable[];
  65666. getActiveTextures(): BABYLON.BaseTexture[];
  65667. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65668. getClassName(): string;
  65669. dispose(forceDisposeEffect?: boolean): void;
  65670. clone(name: string): FireMaterial;
  65671. serialize(): any;
  65672. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  65673. }
  65674. }
  65675. declare module BABYLON {
  65676. /** @hidden */
  65677. export var furPixelShader: {
  65678. name: string;
  65679. shader: string;
  65680. };
  65681. }
  65682. declare module BABYLON {
  65683. /** @hidden */
  65684. export var furVertexShader: {
  65685. name: string;
  65686. shader: string;
  65687. };
  65688. }
  65689. declare module BABYLON {
  65690. export class FurMaterial extends BABYLON.PushMaterial {
  65691. private _diffuseTexture;
  65692. diffuseTexture: BABYLON.BaseTexture;
  65693. private _heightTexture;
  65694. heightTexture: BABYLON.BaseTexture;
  65695. diffuseColor: BABYLON.Color3;
  65696. furLength: number;
  65697. furAngle: number;
  65698. furColor: BABYLON.Color3;
  65699. furOffset: number;
  65700. furSpacing: number;
  65701. furGravity: BABYLON.Vector3;
  65702. furSpeed: number;
  65703. furDensity: number;
  65704. furOcclusion: number;
  65705. furTexture: BABYLON.DynamicTexture;
  65706. private _disableLighting;
  65707. disableLighting: boolean;
  65708. private _maxSimultaneousLights;
  65709. maxSimultaneousLights: number;
  65710. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  65711. private _renderId;
  65712. private _furTime;
  65713. constructor(name: string, scene: BABYLON.Scene);
  65714. furTime: number;
  65715. needAlphaBlending(): boolean;
  65716. needAlphaTesting(): boolean;
  65717. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65718. updateFur(): void;
  65719. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65720. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65721. getAnimatables(): BABYLON.IAnimatable[];
  65722. getActiveTextures(): BABYLON.BaseTexture[];
  65723. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65724. dispose(forceDisposeEffect?: boolean): void;
  65725. clone(name: string): FurMaterial;
  65726. serialize(): any;
  65727. getClassName(): string;
  65728. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  65729. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  65730. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  65731. }
  65732. }
  65733. declare module BABYLON {
  65734. /** @hidden */
  65735. export var gradientPixelShader: {
  65736. name: string;
  65737. shader: string;
  65738. };
  65739. }
  65740. declare module BABYLON {
  65741. /** @hidden */
  65742. export var gradientVertexShader: {
  65743. name: string;
  65744. shader: string;
  65745. };
  65746. }
  65747. declare module BABYLON {
  65748. export class GradientMaterial extends BABYLON.PushMaterial {
  65749. private _maxSimultaneousLights;
  65750. maxSimultaneousLights: number;
  65751. topColor: BABYLON.Color3;
  65752. topColorAlpha: number;
  65753. bottomColor: BABYLON.Color3;
  65754. bottomColorAlpha: number;
  65755. offset: number;
  65756. scale: number;
  65757. smoothness: number;
  65758. private _disableLighting;
  65759. disableLighting: boolean;
  65760. private _renderId;
  65761. constructor(name: string, scene: BABYLON.Scene);
  65762. needAlphaBlending(): boolean;
  65763. needAlphaTesting(): boolean;
  65764. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65765. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65766. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65767. getAnimatables(): BABYLON.IAnimatable[];
  65768. dispose(forceDisposeEffect?: boolean): void;
  65769. clone(name: string): GradientMaterial;
  65770. serialize(): any;
  65771. getClassName(): string;
  65772. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  65773. }
  65774. }
  65775. declare module BABYLON {
  65776. /** @hidden */
  65777. export var gridPixelShader: {
  65778. name: string;
  65779. shader: string;
  65780. };
  65781. }
  65782. declare module BABYLON {
  65783. /** @hidden */
  65784. export var gridVertexShader: {
  65785. name: string;
  65786. shader: string;
  65787. };
  65788. }
  65789. declare module BABYLON {
  65790. /**
  65791. * The grid materials allows you to wrap any shape with a grid.
  65792. * Colors are customizable.
  65793. */
  65794. export class GridMaterial extends BABYLON.PushMaterial {
  65795. /**
  65796. * Main color of the grid (e.g. between lines)
  65797. */
  65798. mainColor: BABYLON.Color3;
  65799. /**
  65800. * Color of the grid lines.
  65801. */
  65802. lineColor: BABYLON.Color3;
  65803. /**
  65804. * The scale of the grid compared to unit.
  65805. */
  65806. gridRatio: number;
  65807. /**
  65808. * Allows setting an offset for the grid lines.
  65809. */
  65810. gridOffset: BABYLON.Vector3;
  65811. /**
  65812. * The frequency of thicker lines.
  65813. */
  65814. majorUnitFrequency: number;
  65815. /**
  65816. * The visibility of minor units in the grid.
  65817. */
  65818. minorUnitVisibility: number;
  65819. /**
  65820. * The grid opacity outside of the lines.
  65821. */
  65822. opacity: number;
  65823. /**
  65824. * Determine RBG output is premultiplied by alpha value.
  65825. */
  65826. preMultiplyAlpha: boolean;
  65827. private _opacityTexture;
  65828. opacityTexture: BABYLON.BaseTexture;
  65829. private _gridControl;
  65830. private _renderId;
  65831. /**
  65832. * constructor
  65833. * @param name The name given to the material in order to identify it afterwards.
  65834. * @param scene The scene the material is used in.
  65835. */
  65836. constructor(name: string, scene: BABYLON.Scene);
  65837. /**
  65838. * Returns wehter or not the grid requires alpha blending.
  65839. */
  65840. needAlphaBlending(): boolean;
  65841. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  65842. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65843. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65844. /**
  65845. * Dispose the material and its associated resources.
  65846. * @param forceDisposeEffect will also dispose the used effect when true
  65847. */
  65848. dispose(forceDisposeEffect?: boolean): void;
  65849. clone(name: string): GridMaterial;
  65850. serialize(): any;
  65851. getClassName(): string;
  65852. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  65853. }
  65854. }
  65855. declare module BABYLON {
  65856. /** @hidden */
  65857. export var lavaPixelShader: {
  65858. name: string;
  65859. shader: string;
  65860. };
  65861. }
  65862. declare module BABYLON {
  65863. /** @hidden */
  65864. export var lavaVertexShader: {
  65865. name: string;
  65866. shader: string;
  65867. };
  65868. }
  65869. declare module BABYLON {
  65870. export class LavaMaterial extends BABYLON.PushMaterial {
  65871. private _diffuseTexture;
  65872. diffuseTexture: BABYLON.BaseTexture;
  65873. noiseTexture: BABYLON.BaseTexture;
  65874. fogColor: BABYLON.Color3;
  65875. speed: number;
  65876. movingSpeed: number;
  65877. lowFrequencySpeed: number;
  65878. fogDensity: number;
  65879. private _lastTime;
  65880. diffuseColor: BABYLON.Color3;
  65881. private _disableLighting;
  65882. disableLighting: boolean;
  65883. private _unlit;
  65884. unlit: boolean;
  65885. private _maxSimultaneousLights;
  65886. maxSimultaneousLights: number;
  65887. private _scaledDiffuse;
  65888. private _renderId;
  65889. constructor(name: string, scene: BABYLON.Scene);
  65890. needAlphaBlending(): boolean;
  65891. needAlphaTesting(): boolean;
  65892. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65893. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65894. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65895. getAnimatables(): BABYLON.IAnimatable[];
  65896. getActiveTextures(): BABYLON.BaseTexture[];
  65897. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65898. dispose(forceDisposeEffect?: boolean): void;
  65899. clone(name: string): LavaMaterial;
  65900. serialize(): any;
  65901. getClassName(): string;
  65902. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  65903. }
  65904. }
  65905. declare module BABYLON {
  65906. /** @hidden */
  65907. export var mixPixelShader: {
  65908. name: string;
  65909. shader: string;
  65910. };
  65911. }
  65912. declare module BABYLON {
  65913. /** @hidden */
  65914. export var mixVertexShader: {
  65915. name: string;
  65916. shader: string;
  65917. };
  65918. }
  65919. declare module BABYLON {
  65920. export class MixMaterial extends BABYLON.PushMaterial {
  65921. /**
  65922. * Mix textures
  65923. */
  65924. private _mixTexture1;
  65925. mixTexture1: BABYLON.BaseTexture;
  65926. private _mixTexture2;
  65927. mixTexture2: BABYLON.BaseTexture;
  65928. /**
  65929. * Diffuse textures
  65930. */
  65931. private _diffuseTexture1;
  65932. diffuseTexture1: BABYLON.Texture;
  65933. private _diffuseTexture2;
  65934. diffuseTexture2: BABYLON.Texture;
  65935. private _diffuseTexture3;
  65936. diffuseTexture3: BABYLON.Texture;
  65937. private _diffuseTexture4;
  65938. diffuseTexture4: BABYLON.Texture;
  65939. private _diffuseTexture5;
  65940. diffuseTexture5: BABYLON.Texture;
  65941. private _diffuseTexture6;
  65942. diffuseTexture6: BABYLON.Texture;
  65943. private _diffuseTexture7;
  65944. diffuseTexture7: BABYLON.Texture;
  65945. private _diffuseTexture8;
  65946. diffuseTexture8: BABYLON.Texture;
  65947. /**
  65948. * Uniforms
  65949. */
  65950. diffuseColor: BABYLON.Color3;
  65951. specularColor: BABYLON.Color3;
  65952. specularPower: number;
  65953. private _disableLighting;
  65954. disableLighting: boolean;
  65955. private _maxSimultaneousLights;
  65956. maxSimultaneousLights: number;
  65957. private _renderId;
  65958. constructor(name: string, scene: BABYLON.Scene);
  65959. needAlphaBlending(): boolean;
  65960. needAlphaTesting(): boolean;
  65961. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  65962. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  65963. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  65964. getAnimatables(): BABYLON.IAnimatable[];
  65965. getActiveTextures(): BABYLON.BaseTexture[];
  65966. hasTexture(texture: BABYLON.BaseTexture): boolean;
  65967. dispose(forceDisposeEffect?: boolean): void;
  65968. clone(name: string): MixMaterial;
  65969. serialize(): any;
  65970. getClassName(): string;
  65971. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  65972. }
  65973. }
  65974. declare module BABYLON {
  65975. /** @hidden */
  65976. export var normalPixelShader: {
  65977. name: string;
  65978. shader: string;
  65979. };
  65980. }
  65981. declare module BABYLON {
  65982. /** @hidden */
  65983. export var normalVertexShader: {
  65984. name: string;
  65985. shader: string;
  65986. };
  65987. }
  65988. declare module BABYLON {
  65989. export class NormalMaterial extends BABYLON.PushMaterial {
  65990. private _diffuseTexture;
  65991. diffuseTexture: BABYLON.BaseTexture;
  65992. diffuseColor: BABYLON.Color3;
  65993. private _disableLighting;
  65994. disableLighting: boolean;
  65995. private _maxSimultaneousLights;
  65996. maxSimultaneousLights: number;
  65997. private _renderId;
  65998. constructor(name: string, scene: BABYLON.Scene);
  65999. needAlphaBlending(): boolean;
  66000. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  66001. needAlphaTesting(): boolean;
  66002. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66003. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66004. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66005. getAnimatables(): BABYLON.IAnimatable[];
  66006. getActiveTextures(): BABYLON.BaseTexture[];
  66007. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66008. dispose(forceDisposeEffect?: boolean): void;
  66009. clone(name: string): NormalMaterial;
  66010. serialize(): any;
  66011. getClassName(): string;
  66012. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  66013. }
  66014. }
  66015. declare module BABYLON {
  66016. /** @hidden */
  66017. export var shadowOnlyPixelShader: {
  66018. name: string;
  66019. shader: string;
  66020. };
  66021. }
  66022. declare module BABYLON {
  66023. /** @hidden */
  66024. export var shadowOnlyVertexShader: {
  66025. name: string;
  66026. shader: string;
  66027. };
  66028. }
  66029. declare module BABYLON {
  66030. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  66031. private _renderId;
  66032. private _activeLight;
  66033. constructor(name: string, scene: BABYLON.Scene);
  66034. shadowColor: BABYLON.Color3;
  66035. needAlphaBlending(): boolean;
  66036. needAlphaTesting(): boolean;
  66037. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66038. activeLight: BABYLON.IShadowLight;
  66039. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66040. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66041. clone(name: string): ShadowOnlyMaterial;
  66042. serialize(): any;
  66043. getClassName(): string;
  66044. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  66045. }
  66046. }
  66047. declare module BABYLON {
  66048. /** @hidden */
  66049. export var simplePixelShader: {
  66050. name: string;
  66051. shader: string;
  66052. };
  66053. }
  66054. declare module BABYLON {
  66055. /** @hidden */
  66056. export var simpleVertexShader: {
  66057. name: string;
  66058. shader: string;
  66059. };
  66060. }
  66061. declare module BABYLON {
  66062. export class SimpleMaterial extends BABYLON.PushMaterial {
  66063. private _diffuseTexture;
  66064. diffuseTexture: BABYLON.BaseTexture;
  66065. diffuseColor: BABYLON.Color3;
  66066. private _disableLighting;
  66067. disableLighting: boolean;
  66068. private _maxSimultaneousLights;
  66069. maxSimultaneousLights: number;
  66070. private _renderId;
  66071. constructor(name: string, scene: BABYLON.Scene);
  66072. needAlphaBlending(): boolean;
  66073. needAlphaTesting(): boolean;
  66074. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66075. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66076. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66077. getAnimatables(): BABYLON.IAnimatable[];
  66078. getActiveTextures(): BABYLON.BaseTexture[];
  66079. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66080. dispose(forceDisposeEffect?: boolean): void;
  66081. clone(name: string): SimpleMaterial;
  66082. serialize(): any;
  66083. getClassName(): string;
  66084. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  66085. }
  66086. }
  66087. declare module BABYLON {
  66088. /** @hidden */
  66089. export var skyPixelShader: {
  66090. name: string;
  66091. shader: string;
  66092. };
  66093. }
  66094. declare module BABYLON {
  66095. /** @hidden */
  66096. export var skyVertexShader: {
  66097. name: string;
  66098. shader: string;
  66099. };
  66100. }
  66101. declare module BABYLON {
  66102. /**
  66103. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  66104. * @see https://doc.babylonjs.com/extensions/sky
  66105. */
  66106. export class SkyMaterial extends BABYLON.PushMaterial {
  66107. /**
  66108. * Defines the overall luminance of sky in interval ]0, 1[.
  66109. */
  66110. luminance: number;
  66111. /**
  66112. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  66113. */
  66114. turbidity: number;
  66115. /**
  66116. * Defines the sky appearance (light intensity).
  66117. */
  66118. rayleigh: number;
  66119. /**
  66120. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  66121. */
  66122. mieCoefficient: number;
  66123. /**
  66124. * Defines the amount of haze particles following the Mie scattering theory.
  66125. */
  66126. mieDirectionalG: number;
  66127. /**
  66128. * Defines the distance of the sun according to the active scene camera.
  66129. */
  66130. distance: number;
  66131. /**
  66132. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  66133. * "inclined".
  66134. */
  66135. inclination: number;
  66136. /**
  66137. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  66138. * an object direction and a reference direction.
  66139. */
  66140. azimuth: number;
  66141. /**
  66142. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  66143. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  66144. */
  66145. sunPosition: BABYLON.Vector3;
  66146. /**
  66147. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  66148. * .sunPosition property.
  66149. */
  66150. useSunPosition: boolean;
  66151. /**
  66152. * Defines an offset vector used to get a horizon offset.
  66153. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  66154. */
  66155. cameraOffset: BABYLON.Vector3;
  66156. private _cameraPosition;
  66157. private _renderId;
  66158. /**
  66159. * Instantiates a new sky material.
  66160. * This material allows to create dynamic and texture free
  66161. * effects for skyboxes by taking care of the atmosphere state.
  66162. * @see https://doc.babylonjs.com/extensions/sky
  66163. * @param name Define the name of the material in the scene
  66164. * @param scene Define the scene the material belong to
  66165. */
  66166. constructor(name: string, scene: BABYLON.Scene);
  66167. /**
  66168. * Specifies if the material will require alpha blending
  66169. * @returns a boolean specifying if alpha blending is needed
  66170. */
  66171. needAlphaBlending(): boolean;
  66172. /**
  66173. * Specifies if this material should be rendered in alpha test mode
  66174. * @returns false as the sky material doesn't need alpha testing.
  66175. */
  66176. needAlphaTesting(): boolean;
  66177. /**
  66178. * Get the texture used for alpha test purpose.
  66179. * @returns null as the sky material has no texture.
  66180. */
  66181. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66182. /**
  66183. * Get if the submesh is ready to be used and all its information available.
  66184. * Child classes can use it to update shaders
  66185. * @param mesh defines the mesh to check
  66186. * @param subMesh defines which submesh to check
  66187. * @param useInstances specifies that instances should be used
  66188. * @returns a boolean indicating that the submesh is ready or not
  66189. */
  66190. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66191. /**
  66192. * Binds the submesh to this material by preparing the effect and shader to draw
  66193. * @param world defines the world transformation matrix
  66194. * @param mesh defines the mesh containing the submesh
  66195. * @param subMesh defines the submesh to bind the material to
  66196. */
  66197. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66198. /**
  66199. * Get the list of animatables in the material.
  66200. * @returns the list of animatables object used in the material
  66201. */
  66202. getAnimatables(): BABYLON.IAnimatable[];
  66203. /**
  66204. * Disposes the material
  66205. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66206. */
  66207. dispose(forceDisposeEffect?: boolean): void;
  66208. /**
  66209. * Makes a duplicate of the material, and gives it a new name
  66210. * @param name defines the new name for the duplicated material
  66211. * @returns the cloned material
  66212. */
  66213. clone(name: string): SkyMaterial;
  66214. /**
  66215. * Serializes this material in a JSON representation
  66216. * @returns the serialized material object
  66217. */
  66218. serialize(): any;
  66219. /**
  66220. * Gets the current class name of the material e.g. "SkyMaterial"
  66221. * Mainly use in serialization.
  66222. * @returns the class name
  66223. */
  66224. getClassName(): string;
  66225. /**
  66226. * Creates a sky material from parsed material data
  66227. * @param source defines the JSON representation of the material
  66228. * @param scene defines the hosting scene
  66229. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66230. * @returns a new sky material
  66231. */
  66232. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  66233. }
  66234. }
  66235. declare module BABYLON {
  66236. /** @hidden */
  66237. export var terrainPixelShader: {
  66238. name: string;
  66239. shader: string;
  66240. };
  66241. }
  66242. declare module BABYLON {
  66243. /** @hidden */
  66244. export var terrainVertexShader: {
  66245. name: string;
  66246. shader: string;
  66247. };
  66248. }
  66249. declare module BABYLON {
  66250. export class TerrainMaterial extends BABYLON.PushMaterial {
  66251. private _mixTexture;
  66252. mixTexture: BABYLON.BaseTexture;
  66253. private _diffuseTexture1;
  66254. diffuseTexture1: BABYLON.Texture;
  66255. private _diffuseTexture2;
  66256. diffuseTexture2: BABYLON.Texture;
  66257. private _diffuseTexture3;
  66258. diffuseTexture3: BABYLON.Texture;
  66259. private _bumpTexture1;
  66260. bumpTexture1: BABYLON.Texture;
  66261. private _bumpTexture2;
  66262. bumpTexture2: BABYLON.Texture;
  66263. private _bumpTexture3;
  66264. bumpTexture3: BABYLON.Texture;
  66265. diffuseColor: BABYLON.Color3;
  66266. specularColor: BABYLON.Color3;
  66267. specularPower: number;
  66268. private _disableLighting;
  66269. disableLighting: boolean;
  66270. private _maxSimultaneousLights;
  66271. maxSimultaneousLights: number;
  66272. private _renderId;
  66273. constructor(name: string, scene: BABYLON.Scene);
  66274. needAlphaBlending(): boolean;
  66275. needAlphaTesting(): boolean;
  66276. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66277. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66278. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66279. getAnimatables(): BABYLON.IAnimatable[];
  66280. getActiveTextures(): BABYLON.BaseTexture[];
  66281. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66282. dispose(forceDisposeEffect?: boolean): void;
  66283. clone(name: string): TerrainMaterial;
  66284. serialize(): any;
  66285. getClassName(): string;
  66286. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  66287. }
  66288. }
  66289. declare module BABYLON {
  66290. /** @hidden */
  66291. export var triplanarPixelShader: {
  66292. name: string;
  66293. shader: string;
  66294. };
  66295. }
  66296. declare module BABYLON {
  66297. /** @hidden */
  66298. export var triplanarVertexShader: {
  66299. name: string;
  66300. shader: string;
  66301. };
  66302. }
  66303. declare module BABYLON {
  66304. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  66305. mixTexture: BABYLON.BaseTexture;
  66306. private _diffuseTextureX;
  66307. diffuseTextureX: BABYLON.BaseTexture;
  66308. private _diffuseTextureY;
  66309. diffuseTextureY: BABYLON.BaseTexture;
  66310. private _diffuseTextureZ;
  66311. diffuseTextureZ: BABYLON.BaseTexture;
  66312. private _normalTextureX;
  66313. normalTextureX: BABYLON.BaseTexture;
  66314. private _normalTextureY;
  66315. normalTextureY: BABYLON.BaseTexture;
  66316. private _normalTextureZ;
  66317. normalTextureZ: BABYLON.BaseTexture;
  66318. tileSize: number;
  66319. diffuseColor: BABYLON.Color3;
  66320. specularColor: BABYLON.Color3;
  66321. specularPower: number;
  66322. private _disableLighting;
  66323. disableLighting: boolean;
  66324. private _maxSimultaneousLights;
  66325. maxSimultaneousLights: number;
  66326. private _renderId;
  66327. constructor(name: string, scene: BABYLON.Scene);
  66328. needAlphaBlending(): boolean;
  66329. needAlphaTesting(): boolean;
  66330. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66331. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66332. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66333. getAnimatables(): BABYLON.IAnimatable[];
  66334. getActiveTextures(): BABYLON.BaseTexture[];
  66335. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66336. dispose(forceDisposeEffect?: boolean): void;
  66337. clone(name: string): TriPlanarMaterial;
  66338. serialize(): any;
  66339. getClassName(): string;
  66340. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  66341. }
  66342. }
  66343. declare module BABYLON {
  66344. /** @hidden */
  66345. export var waterPixelShader: {
  66346. name: string;
  66347. shader: string;
  66348. };
  66349. }
  66350. declare module BABYLON {
  66351. /** @hidden */
  66352. export var waterVertexShader: {
  66353. name: string;
  66354. shader: string;
  66355. };
  66356. }
  66357. declare module BABYLON {
  66358. export class WaterMaterial extends BABYLON.PushMaterial {
  66359. renderTargetSize: BABYLON.Vector2;
  66360. private _bumpTexture;
  66361. bumpTexture: BABYLON.BaseTexture;
  66362. diffuseColor: BABYLON.Color3;
  66363. specularColor: BABYLON.Color3;
  66364. specularPower: number;
  66365. private _disableLighting;
  66366. disableLighting: boolean;
  66367. private _maxSimultaneousLights;
  66368. maxSimultaneousLights: number;
  66369. /**
  66370. * @param {number}: Represents the wind force
  66371. */
  66372. windForce: number;
  66373. /**
  66374. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  66375. */
  66376. windDirection: BABYLON.Vector2;
  66377. /**
  66378. * @param {number}: Wave height, represents the height of the waves
  66379. */
  66380. waveHeight: number;
  66381. /**
  66382. * @param {number}: Bump height, represents the bump height related to the bump map
  66383. */
  66384. bumpHeight: number;
  66385. /**
  66386. * @param {boolean}: Add a smaller moving bump to less steady waves.
  66387. */
  66388. private _bumpSuperimpose;
  66389. bumpSuperimpose: boolean;
  66390. /**
  66391. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  66392. */
  66393. private _fresnelSeparate;
  66394. fresnelSeparate: boolean;
  66395. /**
  66396. * @param {boolean}: bump Waves modify the reflection.
  66397. */
  66398. private _bumpAffectsReflection;
  66399. bumpAffectsReflection: boolean;
  66400. /**
  66401. * @param {number}: The water color blended with the refraction (near)
  66402. */
  66403. waterColor: BABYLON.Color3;
  66404. /**
  66405. * @param {number}: The blend factor related to the water color
  66406. */
  66407. colorBlendFactor: number;
  66408. /**
  66409. * @param {number}: The water color blended with the reflection (far)
  66410. */
  66411. waterColor2: BABYLON.Color3;
  66412. /**
  66413. * @param {number}: The blend factor related to the water color (reflection, far)
  66414. */
  66415. colorBlendFactor2: number;
  66416. /**
  66417. * @param {number}: Represents the maximum length of a wave
  66418. */
  66419. waveLength: number;
  66420. /**
  66421. * @param {number}: Defines the waves speed
  66422. */
  66423. waveSpeed: number;
  66424. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  66425. private _mesh;
  66426. private _refractionRTT;
  66427. private _reflectionRTT;
  66428. private _reflectionTransform;
  66429. private _lastTime;
  66430. private _lastDeltaTime;
  66431. private _renderId;
  66432. private _useLogarithmicDepth;
  66433. private _waitingRenderList;
  66434. /**
  66435. * Gets a boolean indicating that current material needs to register RTT
  66436. */
  66437. readonly hasRenderTargetTextures: boolean;
  66438. /**
  66439. * Constructor
  66440. */
  66441. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  66442. useLogarithmicDepth: boolean;
  66443. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  66444. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  66445. addToRenderList(node: any): void;
  66446. enableRenderTargets(enable: boolean): void;
  66447. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  66448. readonly renderTargetsEnabled: boolean;
  66449. needAlphaBlending(): boolean;
  66450. needAlphaTesting(): boolean;
  66451. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  66452. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  66453. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  66454. private _createRenderTargets;
  66455. getAnimatables(): BABYLON.IAnimatable[];
  66456. getActiveTextures(): BABYLON.BaseTexture[];
  66457. hasTexture(texture: BABYLON.BaseTexture): boolean;
  66458. dispose(forceDisposeEffect?: boolean): void;
  66459. clone(name: string): WaterMaterial;
  66460. serialize(): any;
  66461. getClassName(): string;
  66462. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  66463. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  66464. }
  66465. }
  66466. declare module BABYLON {
  66467. /** @hidden */
  66468. export var asciiartPixelShader: {
  66469. name: string;
  66470. shader: string;
  66471. };
  66472. }
  66473. declare module BABYLON {
  66474. /**
  66475. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  66476. *
  66477. * It basically takes care rendering the font front the given font size to a texture.
  66478. * This is used later on in the postprocess.
  66479. */
  66480. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  66481. private _font;
  66482. private _text;
  66483. private _charSize;
  66484. /**
  66485. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  66486. */
  66487. readonly charSize: number;
  66488. /**
  66489. * Create a new instance of the Ascii Art FontTexture class
  66490. * @param name the name of the texture
  66491. * @param font the font to use, use the W3C CSS notation
  66492. * @param text the caracter set to use in the rendering.
  66493. * @param scene the scene that owns the texture
  66494. */
  66495. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  66496. /**
  66497. * Gets the max char width of a font.
  66498. * @param font the font to use, use the W3C CSS notation
  66499. * @return the max char width
  66500. */
  66501. private getFontWidth;
  66502. /**
  66503. * Gets the max char height of a font.
  66504. * @param font the font to use, use the W3C CSS notation
  66505. * @return the max char height
  66506. */
  66507. private getFontHeight;
  66508. /**
  66509. * Clones the current AsciiArtTexture.
  66510. * @return the clone of the texture.
  66511. */
  66512. clone(): AsciiArtFontTexture;
  66513. /**
  66514. * Parses a json object representing the texture and returns an instance of it.
  66515. * @param source the source JSON representation
  66516. * @param scene the scene to create the texture for
  66517. * @return the parsed texture
  66518. */
  66519. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  66520. }
  66521. /**
  66522. * Option available in the Ascii Art Post Process.
  66523. */
  66524. export interface IAsciiArtPostProcessOptions {
  66525. /**
  66526. * The font to use following the w3c font definition.
  66527. */
  66528. font?: string;
  66529. /**
  66530. * The character set to use in the postprocess.
  66531. */
  66532. characterSet?: string;
  66533. /**
  66534. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  66535. * This number is defined between 0 and 1;
  66536. */
  66537. mixToTile?: number;
  66538. /**
  66539. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  66540. * This number is defined between 0 and 1;
  66541. */
  66542. mixToNormal?: number;
  66543. }
  66544. /**
  66545. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  66546. *
  66547. * Simmply add it to your scene and let the nerd that lives in you have fun.
  66548. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  66549. */
  66550. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  66551. /**
  66552. * The font texture used to render the char in the post process.
  66553. */
  66554. private _asciiArtFontTexture;
  66555. /**
  66556. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  66557. * This number is defined between 0 and 1;
  66558. */
  66559. mixToTile: number;
  66560. /**
  66561. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  66562. * This number is defined between 0 and 1;
  66563. */
  66564. mixToNormal: number;
  66565. /**
  66566. * Instantiates a new Ascii Art Post Process.
  66567. * @param name the name to give to the postprocess
  66568. * @camera the camera to apply the post process to.
  66569. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  66570. */
  66571. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  66572. }
  66573. }
  66574. declare module BABYLON {
  66575. /** @hidden */
  66576. export var digitalrainPixelShader: {
  66577. name: string;
  66578. shader: string;
  66579. };
  66580. }
  66581. declare module BABYLON {
  66582. /**
  66583. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  66584. *
  66585. * It basically takes care rendering the font front the given font size to a texture.
  66586. * This is used later on in the postprocess.
  66587. */
  66588. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  66589. private _font;
  66590. private _text;
  66591. private _charSize;
  66592. /**
  66593. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  66594. */
  66595. readonly charSize: number;
  66596. /**
  66597. * Create a new instance of the Digital Rain FontTexture class
  66598. * @param name the name of the texture
  66599. * @param font the font to use, use the W3C CSS notation
  66600. * @param text the caracter set to use in the rendering.
  66601. * @param scene the scene that owns the texture
  66602. */
  66603. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  66604. /**
  66605. * Gets the max char width of a font.
  66606. * @param font the font to use, use the W3C CSS notation
  66607. * @return the max char width
  66608. */
  66609. private getFontWidth;
  66610. /**
  66611. * Gets the max char height of a font.
  66612. * @param font the font to use, use the W3C CSS notation
  66613. * @return the max char height
  66614. */
  66615. private getFontHeight;
  66616. /**
  66617. * Clones the current DigitalRainFontTexture.
  66618. * @return the clone of the texture.
  66619. */
  66620. clone(): DigitalRainFontTexture;
  66621. /**
  66622. * Parses a json object representing the texture and returns an instance of it.
  66623. * @param source the source JSON representation
  66624. * @param scene the scene to create the texture for
  66625. * @return the parsed texture
  66626. */
  66627. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  66628. }
  66629. /**
  66630. * Option available in the Digital Rain Post Process.
  66631. */
  66632. export interface IDigitalRainPostProcessOptions {
  66633. /**
  66634. * The font to use following the w3c font definition.
  66635. */
  66636. font?: string;
  66637. /**
  66638. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  66639. * This number is defined between 0 and 1;
  66640. */
  66641. mixToTile?: number;
  66642. /**
  66643. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  66644. * This number is defined between 0 and 1;
  66645. */
  66646. mixToNormal?: number;
  66647. }
  66648. /**
  66649. * DigitalRainPostProcess helps rendering everithing in digital rain.
  66650. *
  66651. * Simmply add it to your scene and let the nerd that lives in you have fun.
  66652. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  66653. */
  66654. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  66655. /**
  66656. * The font texture used to render the char in the post process.
  66657. */
  66658. private _digitalRainFontTexture;
  66659. /**
  66660. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  66661. * This number is defined between 0 and 1;
  66662. */
  66663. mixToTile: number;
  66664. /**
  66665. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  66666. * This number is defined between 0 and 1;
  66667. */
  66668. mixToNormal: number;
  66669. /**
  66670. * Instantiates a new Digital Rain Post Process.
  66671. * @param name the name to give to the postprocess
  66672. * @camera the camera to apply the post process to.
  66673. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  66674. */
  66675. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  66676. }
  66677. }
  66678. declare module BABYLON {
  66679. /** @hidden */
  66680. export var oceanPostProcessPixelShader: {
  66681. name: string;
  66682. shader: string;
  66683. };
  66684. }
  66685. declare module BABYLON {
  66686. /**
  66687. * Option available in the Ocean Post Process.
  66688. */
  66689. export interface IOceanPostProcessOptions {
  66690. /**
  66691. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  66692. */
  66693. reflectionSize?: number | {
  66694. width: number;
  66695. height: number;
  66696. } | {
  66697. ratio: number;
  66698. };
  66699. /**
  66700. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  66701. */
  66702. refractionSize?: number | {
  66703. width: number;
  66704. height: number;
  66705. } | {
  66706. ratio: number;
  66707. };
  66708. }
  66709. /**
  66710. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  66711. *
  66712. * Simmply add it to your scene and let the nerd that lives in you have fun.
  66713. * Example usage:
  66714. * var pp = new OceanPostProcess("myOcean", camera);
  66715. * pp.reflectionEnabled = true;
  66716. * pp.refractionEnabled = true;
  66717. */
  66718. export class OceanPostProcess extends BABYLON.PostProcess {
  66719. /**
  66720. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  66721. */
  66722. /**
  66723. * Sets weither or not the real-time reflection is enabled on the ocean.
  66724. * Is set to true, the reflection mirror texture will be used as reflection texture.
  66725. */
  66726. reflectionEnabled: boolean;
  66727. /**
  66728. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  66729. */
  66730. /**
  66731. * Sets weither or not the real-time refraction is enabled on the ocean.
  66732. * Is set to true, the refraction render target texture will be used as refraction texture.
  66733. */
  66734. refractionEnabled: boolean;
  66735. /**
  66736. * Gets wether or not the post-processes is supported by the running hardware.
  66737. * This requires draw buffer supports.
  66738. */
  66739. readonly isSupported: boolean;
  66740. /**
  66741. * This is the reflection mirror texture used to display reflections on the ocean.
  66742. * By default, render list is empty.
  66743. */
  66744. reflectionTexture: BABYLON.MirrorTexture;
  66745. /**
  66746. * This is the refraction render target texture used to display refraction on the ocean.
  66747. * By default, render list is empty.
  66748. */
  66749. refractionTexture: BABYLON.RenderTargetTexture;
  66750. private _time;
  66751. private _cameraRotation;
  66752. private _cameraViewMatrix;
  66753. private _reflectionEnabled;
  66754. private _refractionEnabled;
  66755. private _geometryRenderer;
  66756. /**
  66757. * Instantiates a new Ocean Post Process.
  66758. * @param name the name to give to the postprocess.
  66759. * @camera the camera to apply the post process to.
  66760. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  66761. */
  66762. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  66763. /**
  66764. * Returns the appropriate defines according to the current configuration.
  66765. */
  66766. private _getDefines;
  66767. /**
  66768. * Computes the current camera rotation as the shader requires a camera rotation.
  66769. */
  66770. private _computeCameraRotation;
  66771. }
  66772. }
  66773. declare module BABYLON {
  66774. /** @hidden */
  66775. export var brickProceduralTexturePixelShader: {
  66776. name: string;
  66777. shader: string;
  66778. };
  66779. }
  66780. declare module BABYLON {
  66781. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  66782. private _numberOfBricksHeight;
  66783. private _numberOfBricksWidth;
  66784. private _jointColor;
  66785. private _brickColor;
  66786. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66787. updateShaderUniforms(): void;
  66788. numberOfBricksHeight: number;
  66789. numberOfBricksWidth: number;
  66790. jointColor: BABYLON.Color3;
  66791. brickColor: BABYLON.Color3;
  66792. /**
  66793. * Serializes this brick procedural texture
  66794. * @returns a serialized brick procedural texture object
  66795. */
  66796. serialize(): any;
  66797. /**
  66798. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  66799. * @param parsedTexture defines parsed texture data
  66800. * @param scene defines the current scene
  66801. * @param rootUrl defines the root URL containing brick procedural texture information
  66802. * @returns a parsed Brick Procedural BABYLON.Texture
  66803. */
  66804. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  66805. }
  66806. }
  66807. declare module BABYLON {
  66808. /** @hidden */
  66809. export var cloudProceduralTexturePixelShader: {
  66810. name: string;
  66811. shader: string;
  66812. };
  66813. }
  66814. declare module BABYLON {
  66815. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  66816. private _skyColor;
  66817. private _cloudColor;
  66818. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66819. updateShaderUniforms(): void;
  66820. skyColor: BABYLON.Color4;
  66821. cloudColor: BABYLON.Color4;
  66822. /**
  66823. * Serializes this cloud procedural texture
  66824. * @returns a serialized cloud procedural texture object
  66825. */
  66826. serialize(): any;
  66827. /**
  66828. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  66829. * @param parsedTexture defines parsed texture data
  66830. * @param scene defines the current scene
  66831. * @param rootUrl defines the root URL containing cloud procedural texture information
  66832. * @returns a parsed Cloud Procedural BABYLON.Texture
  66833. */
  66834. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  66835. }
  66836. }
  66837. declare module BABYLON {
  66838. /** @hidden */
  66839. export var fireProceduralTexturePixelShader: {
  66840. name: string;
  66841. shader: string;
  66842. };
  66843. }
  66844. declare module BABYLON {
  66845. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  66846. private _time;
  66847. private _speed;
  66848. private _autoGenerateTime;
  66849. private _fireColors;
  66850. private _alphaThreshold;
  66851. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66852. updateShaderUniforms(): void;
  66853. render(useCameraPostProcess?: boolean): void;
  66854. static readonly PurpleFireColors: BABYLON.Color3[];
  66855. static readonly GreenFireColors: BABYLON.Color3[];
  66856. static readonly RedFireColors: BABYLON.Color3[];
  66857. static readonly BlueFireColors: BABYLON.Color3[];
  66858. autoGenerateTime: boolean;
  66859. fireColors: BABYLON.Color3[];
  66860. time: number;
  66861. speed: BABYLON.Vector2;
  66862. alphaThreshold: number;
  66863. /**
  66864. * Serializes this fire procedural texture
  66865. * @returns a serialized fire procedural texture object
  66866. */
  66867. serialize(): any;
  66868. /**
  66869. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  66870. * @param parsedTexture defines parsed texture data
  66871. * @param scene defines the current scene
  66872. * @param rootUrl defines the root URL containing fire procedural texture information
  66873. * @returns a parsed Fire Procedural BABYLON.Texture
  66874. */
  66875. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  66876. }
  66877. }
  66878. declare module BABYLON {
  66879. /** @hidden */
  66880. export var grassProceduralTexturePixelShader: {
  66881. name: string;
  66882. shader: string;
  66883. };
  66884. }
  66885. declare module BABYLON {
  66886. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  66887. private _grassColors;
  66888. private _groundColor;
  66889. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66890. updateShaderUniforms(): void;
  66891. grassColors: BABYLON.Color3[];
  66892. groundColor: BABYLON.Color3;
  66893. /**
  66894. * Serializes this grass procedural texture
  66895. * @returns a serialized grass procedural texture object
  66896. */
  66897. serialize(): any;
  66898. /**
  66899. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  66900. * @param parsedTexture defines parsed texture data
  66901. * @param scene defines the current scene
  66902. * @param rootUrl defines the root URL containing grass procedural texture information
  66903. * @returns a parsed Grass Procedural BABYLON.Texture
  66904. */
  66905. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  66906. }
  66907. }
  66908. declare module BABYLON {
  66909. /** @hidden */
  66910. export var marbleProceduralTexturePixelShader: {
  66911. name: string;
  66912. shader: string;
  66913. };
  66914. }
  66915. declare module BABYLON {
  66916. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  66917. private _numberOfTilesHeight;
  66918. private _numberOfTilesWidth;
  66919. private _amplitude;
  66920. private _jointColor;
  66921. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66922. updateShaderUniforms(): void;
  66923. numberOfTilesHeight: number;
  66924. amplitude: number;
  66925. numberOfTilesWidth: number;
  66926. jointColor: BABYLON.Color3;
  66927. /**
  66928. * Serializes this marble procedural texture
  66929. * @returns a serialized marble procedural texture object
  66930. */
  66931. serialize(): any;
  66932. /**
  66933. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  66934. * @param parsedTexture defines parsed texture data
  66935. * @param scene defines the current scene
  66936. * @param rootUrl defines the root URL containing marble procedural texture information
  66937. * @returns a parsed Marble Procedural BABYLON.Texture
  66938. */
  66939. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  66940. }
  66941. }
  66942. declare module BABYLON {
  66943. /** @hidden */
  66944. export var normalMapProceduralTexturePixelShader: {
  66945. name: string;
  66946. shader: string;
  66947. };
  66948. }
  66949. declare module BABYLON {
  66950. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  66951. private _baseTexture;
  66952. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66953. updateShaderUniforms(): void;
  66954. render(useCameraPostProcess?: boolean): void;
  66955. resize(size: any, generateMipMaps: any): void;
  66956. baseTexture: BABYLON.Texture;
  66957. /**
  66958. * Serializes this normal map procedural texture
  66959. * @returns a serialized normal map procedural texture object
  66960. */
  66961. serialize(): any;
  66962. /**
  66963. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  66964. * @param parsedTexture defines parsed texture data
  66965. * @param scene defines the current scene
  66966. * @param rootUrl defines the root URL containing normal map procedural texture information
  66967. * @returns a parsed Normal Map Procedural BABYLON.Texture
  66968. */
  66969. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  66970. }
  66971. }
  66972. declare module BABYLON {
  66973. /** @hidden */
  66974. export var perlinNoiseProceduralTexturePixelShader: {
  66975. name: string;
  66976. shader: string;
  66977. };
  66978. }
  66979. declare module BABYLON {
  66980. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  66981. time: number;
  66982. timeScale: number;
  66983. translationSpeed: number;
  66984. private _currentTranslation;
  66985. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  66986. updateShaderUniforms(): void;
  66987. render(useCameraPostProcess?: boolean): void;
  66988. resize(size: any, generateMipMaps: any): void;
  66989. /**
  66990. * Serializes this perlin noise procedural texture
  66991. * @returns a serialized perlin noise procedural texture object
  66992. */
  66993. serialize(): any;
  66994. /**
  66995. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  66996. * @param parsedTexture defines parsed texture data
  66997. * @param scene defines the current scene
  66998. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  66999. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  67000. */
  67001. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  67002. }
  67003. }
  67004. declare module BABYLON {
  67005. /** @hidden */
  67006. export var roadProceduralTexturePixelShader: {
  67007. name: string;
  67008. shader: string;
  67009. };
  67010. }
  67011. declare module BABYLON {
  67012. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  67013. private _roadColor;
  67014. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67015. updateShaderUniforms(): void;
  67016. roadColor: BABYLON.Color3;
  67017. /**
  67018. * Serializes this road procedural texture
  67019. * @returns a serialized road procedural texture object
  67020. */
  67021. serialize(): any;
  67022. /**
  67023. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  67024. * @param parsedTexture defines parsed texture data
  67025. * @param scene defines the current scene
  67026. * @param rootUrl defines the root URL containing road procedural texture information
  67027. * @returns a parsed Road Procedural BABYLON.Texture
  67028. */
  67029. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  67030. }
  67031. }
  67032. declare module BABYLON {
  67033. /** @hidden */
  67034. export var starfieldProceduralTexturePixelShader: {
  67035. name: string;
  67036. shader: string;
  67037. };
  67038. }
  67039. declare module BABYLON {
  67040. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  67041. private _time;
  67042. private _alpha;
  67043. private _beta;
  67044. private _zoom;
  67045. private _formuparam;
  67046. private _stepsize;
  67047. private _tile;
  67048. private _brightness;
  67049. private _darkmatter;
  67050. private _distfading;
  67051. private _saturation;
  67052. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67053. updateShaderUniforms(): void;
  67054. time: number;
  67055. alpha: number;
  67056. beta: number;
  67057. formuparam: number;
  67058. stepsize: number;
  67059. zoom: number;
  67060. tile: number;
  67061. brightness: number;
  67062. darkmatter: number;
  67063. distfading: number;
  67064. saturation: number;
  67065. /**
  67066. * Serializes this starfield procedural texture
  67067. * @returns a serialized starfield procedural texture object
  67068. */
  67069. serialize(): any;
  67070. /**
  67071. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  67072. * @param parsedTexture defines parsed texture data
  67073. * @param scene defines the current scene
  67074. * @param rootUrl defines the root URL containing startfield procedural texture information
  67075. * @returns a parsed Starfield Procedural BABYLON.Texture
  67076. */
  67077. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  67078. }
  67079. }
  67080. declare module BABYLON {
  67081. /** @hidden */
  67082. export var woodProceduralTexturePixelShader: {
  67083. name: string;
  67084. shader: string;
  67085. };
  67086. }
  67087. declare module BABYLON {
  67088. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  67089. private _ampScale;
  67090. private _woodColor;
  67091. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  67092. updateShaderUniforms(): void;
  67093. ampScale: number;
  67094. woodColor: BABYLON.Color3;
  67095. /**
  67096. * Serializes this wood procedural texture
  67097. * @returns a serialized wood procedural texture object
  67098. */
  67099. serialize(): any;
  67100. /**
  67101. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  67102. * @param parsedTexture defines parsed texture data
  67103. * @param scene defines the current scene
  67104. * @param rootUrl defines the root URL containing wood procedural texture information
  67105. * @returns a parsed Wood Procedural BABYLON.Texture
  67106. */
  67107. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  67108. }
  67109. }